0

I'm using fscalender in my project. I have to choose start date and end date,in which when user selected start date the end date calendar view should disable the previous dates of selected date.How can I achieve this.

`

 var satrtDte:Date?
`func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
        if isFromEndDate == true{
            if let start = satrtDte{
                if date .compare(start) == .orderedAscending {
                    return false
                    
                }else {
                    return true
                }
            }
            
        }
        return true
    }

`` satrtDte contains start Date

1 Answers1

0

You can use two method from the delegate FSCalendarDataSource to select start and end date:

    var startDate: Date() = // declare your start Date
    var endDate: Date() = // declare your end Date

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

    func maximumDate(for calendar: FSCalendar) -> Date {
        return endDate
    }
  • func minimumDate(for calendar: FSCalendar) -> Date { if isFromToDate == true{ return satrtDte } return } in this case when this condition is true then I have to set minimum dates otherwise I have to view the calendar as it is so my question is what should I return In this else case – NIMISHA RAJEEV P Oct 25 '22 at 18:02
  • 1
    If i undertood this correctly I think you can return `Date(timeIntervalSince1970: 0)`, in this way you will have 00:00:00 UTC on 1 January 1970, that shoul be the start of the Date type. More information here https://developer.apple.com/documentation/foundation/date/1780353-init – leobartowski Oct 25 '22 at 22:47