Reputation: 1864
I am using FSCalender for ma project. I need to scroll the calender for getting next month.
I am using this code to get the change notification
func calendarCurrentMonthDidChange(_ calendar: FSCalendar!) {
print("Changed")
print("ss",ss)
// Do something
}
what I need is to get the current month and year form the calendar object..
Upvotes: 0
Views: 7012
Reputation: 2269
You can use this as mentioned in https://github.com/WenchaoD/FSCalendar/issues/508
let values = Calendar.current.dateComponents([Calendar.Component.month, Calendar.Component.year], from: self.calendar.currentPage)
CURRENT_YEAR = values.year
CURRENT_MONTH = values.month
let range = Calendar.current.range(of: Calendar.Component.day, in: Calendar.Component.month, for: self.calendar.currentPage)
TOTAL_DAYS = range.count
Upvotes: 1
Reputation: 3538
You can use the calendar.currentPage
to get the Date
value. Then use Component
let currentPageDate = calendar.currentPage
let month = Calendar.current.component(.month, from: currentPageDate)
print(month)
Upvotes: 14