Hi,
I discover a problem with the last version of the library, I want to put the month name on the header on each month.
I make a vertical scroll and itemSize = 50.
I use this to take the month on the header.
func calendar(_ calendar: JTAppleCalendarView, willDisplaySectionHeader header: JTAppleHeaderView, range: (start: Date, end: Date), identifier: String) {
switch identifier {
case "MonthHeaderFirstView":
let headerCell = (header as? MonthHeaderFirstController)
let startDate = range.start
print("RANGE START: \(range.start)")
let month = currentCalendar.dateComponents([.month], from: startDate).month!
let year = currentCalendar.component(.year, from: startDate)
headerCell?.firstMonthLabel.text = String(month) + " - " + String(year)
break;
case "MonthHeaderSecondView":
let headerCell = (header as? MonthHeaderSecondController)
let endDate = range.end
print("RANGE END: \(range.end)")
print("--------------------------")
let month = currentCalendar.dateComponents([.month], from: endDate).month!
let year = currentCalendar.component(.year, from: endDate)
headerCell?.secondMonthLabel.text = String(month) + " - " + String(year)
break;
default:
let headerCell = (header as? MonthHeaderFirstController)
let startDate = range.start
let month = currentCalendar.dateComponents([.month], from: startDate).month!
let year = currentCalendar.component(.year, from: startDate)
headerCell?.firstMonthLabel.text = String(month) + " - " + String(year)
break;
}
}
func calendar(_ calendar: JTAppleCalendarView, sectionHeaderIdentifierFor range: (start: Date, end: Date), belongingTo month: Int) -> String {
if month % 2 > 0 {
return "MonthHeaderFirstView"
}
return "MonthHeaderSecondView"
}
But It has a problem on February and some months, the range start will return this "2017-02-28 23:00:00 +0000"
Here's a screenshot.

I hope you can help me :)
Thanks.
I do not understand the last part of your question.
You said
the range start will return this "2017-02-28 23:00:00 +0000"
Which function is returning this?
Is it returning this for all the months?
Based on your question, I am not sure what the problem is. For me to know the problem, I neeed to know what you are getting and what was supposed to be the expected result, and how they are different.
I want to put the month number on the header in the calendar, how can I do it?
My calendar shows max. 2 headers at the same time on the screen.
I did this:
func calendar(_ calendar: JTAppleCalendarView, willDisplaySectionHeader header: JTAppleHeaderView, range: (start: Date, end: Date), identifier: String) {
let date = range.start
let month = testCalendar.component(.month, from: date)
// etc etc
And it works well.
Can you tell me what version number of the calendar you are using?
Also, i will be available here in some time -> https://gitter.im/patchthecode/JTAppleCalendar in about 1hr or so
I use the last versi贸n 6.1.2.
I'll try your code later, I'll tell you if it works ;)
I can't try this now, I'll try it on Monday at Work.
I'll tell you if it works.
Thanks ;D
It works, thank you so much :D
Awesome. I'll close this issue now.
Btw, you calendar looks very cool. Why dont you post its picture here --> https://github.com/patchthecode/JTAppleCalendar/issues/216 ?
cheers man.
Most helpful comment
I did this:
And it works well.
Can you tell me what version number of the calendar you are using?
Also, i will be available here in some time -> https://gitter.im/patchthecode/JTAppleCalendar in about 1hr or so