Inside func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool
i am getting date of one day back , am i doing something wrong can you please help me .
I am facing same issue.
We are getting same issue
i fixed this with category for Date:
extension Date {
// Convert UTC (or GMT) to local time
func toLocalTime() -> Date {
let timezone = TimeZone.current
let seconds = TimeInterval(timezone.secondsFromGMT(for: self))
return Date(timeInterval: seconds, since: self)
}
// Convert local time to UTC (or GMT)
func toGlobalTime() -> Date {
let timezone = TimeZone.current
let seconds = -TimeInterval(timezone.secondsFromGMT(for: self))
return Date(timeInterval: seconds, since: self)
}
}
and convert it in selectDate delegate:
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
print("did select date \(date)")
let date = date.toLocalTime()
}
This answer helped me thanks saved my time
Cool @vitalrum, I am closing the issue now as I am also getting the same day.
Most helpful comment
i fixed this with category for Date:
and convert it in selectDate delegate: