Fscalendar: Possible to provide minimum and maximum date for calendar?

Created on 2 Apr 2016  路  7Comments  路  Source: WenchaoD/FSCalendar

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!

Most helpful comment

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")!
}

All 7 comments

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

User this

// FSCalendarDataSource

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

same for maximum.

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")!
}

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.

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

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

refs #870

Was this page helpful?
0 / 5 - 0 ratings

Related issues

csimmons0 picture csimmons0  路  4Comments

ghost picture ghost  路  5Comments

thaoth58 picture thaoth58  路  3Comments

denikaev picture denikaev  路  5Comments

KushThakkar picture KushThakkar  路  6Comments