0

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..

Saneesh
  • 1,796
  • 16
  • 23

2 Answers2

13

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)
xmhafiz
  • 3,482
  • 1
  • 18
  • 26
1

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
Aakash
  • 2,239
  • 15
  • 23