FSCalendar: Get Start and End date of current view

Viewed 1927

How can I get current calendar start and end date?

From the screenshot, I need to get Sep 24 2017 and Nov 4 2017..

thanks![enter image description here]1

2 Answers

Here is how you can see the first and last visible date

let startDate: Date?
let endDate: Date?
if self.calendar.scope == .week {
    startDate = self.calendar.currentPage
    endDate = self.calendar.gregorian.date(byAdding: .day, value: 6, to: startDate)
} else { // .month
    let indexPath = self.calendar.calculator.indexPath(for: self.calendar.currentPage, scope: .month)
    startDate = self.calendar.calculator.monthHead(forSection: (indexPath?.section)!)!
    endDate = self.calendar.gregorian.date(byAdding: .day, value: 41, to: startDate)
}

The answer is originally mentioned in this thread

Related