Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to provide minimum and maximum date for calendar? #250

Closed
simonarcher opened this issue Apr 2, 2016 · 9 comments
Closed

Possible to provide minimum and maximum date for calendar? #250

simonarcher opened this issue Apr 2, 2016 · 9 comments

Comments

@simonarcher
Copy link

Hi there!

I like you library, and hoping to use it my app, but before I do I just want to know if the following is possible... (I tried to figure it out, but couldnt :( )

Is it possible to set a minimum and maximum date for the calendar selection? For instance I dont want users to select anything in the future, and how many days in the past would have to be configurable based on the context.

I see there is a 'minimumDate' and 'maximumDate' properties, but seem to be readOnly.

Any idea if the above request is possible?

Thanks again!

@simonarcher
Copy link
Author

my bad! just saw it was there in the Swift project. :) thanks!

@HariMohanAgrawal
Copy link

User this

// FSCalendarDataSource

  • (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
    {
    return [NSDate date];
    }

same for maximum.

@rpapallas
Copy link

fileprivate lazy var dateFormatter: DateFormatter = {
    let formatter = DateFormatter()
    formatter.dateFormat = "yyyy-MM-dd"
    return formatter
}()
    
func minimumDate(for calendar: FSCalendar) -> Date {
    return self.dateFormatter.date(from: "2018-01-01")!
}
    
func maximumDate(for calendar: FSCalendar) -> Date {
    return self.dateFormatter.date(from: "2018-02-28")!
}

@idevChandra6
Copy link

These two methods are not getting called. Delegate is not nil. All other delegates methods are getting called.
What I was trying is... I want calendar to start with today's date so that user would not select past dates and only show 3 months from today.
For this I have to use these two methods only but they are not getting called.

@NirajCapermint
Copy link

NirajCapermint commented Mar 13, 2019

func minimumDate(for calendar: FSCalendar) -> Date { return Date() }

@ykws
Copy link

ykws commented Mar 22, 2019

@idevChandra6
Hi, use FSCalendarDatasource instead of FSCalendarDelegate
Best regards.

@ykws
Copy link

ykws commented Mar 22, 2019

refs #870

ykws added a commit to ykws/FSCalendar that referenced this issue Mar 22, 2019
ykws added a commit to ykws/FSCalendar that referenced this issue Mar 22, 2019
@Farazahmed90
Copy link

Farazahmed90 commented Jul 29, 2021

Hello, is there any way to don't show extra dates in fscalendar other than minimum and maximum date swift
I want to do same thing like below image

Screenshot 2021-07-29 at 11 45 10 AM

@jmanalang3
Copy link

`fileprivate lazy var dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
return formatter
}()

func minimumDate(for calendar: FSCalendar) -> Date {
return self.dateFormatter.date(from: "2018-01-01")!
}

func maximumDate(for calendar: FSCalendar) -> Date {
return self.dateFormatter.date(from: "2018-02-28")!
}`

this is not working, the dataSource is always nil on the first initial call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants