I am working on a project which lists different project locations, each project locations are associated with the different timezones. I am using FSCalendar for displaying date of the currently selected project in its timezone. I am not able to correctly display the date on FSCalendar View.
I want to show the date on FSCalendar view irrespective of time zone configured in the device. Meaning even if the user changes the timezone manually going to setting in the device, the this change should not affect in my project calendar. (eg: Automatic timezone will be selected usually in all devices)
To achieve this i have to configure FSCalendar with the selected project timezone.
I have tried converting the Date() to Project time zone using DateFormatter(). Tried DST calculations.
func isDateInProjectTimeZone() -> Bool {
if let projectTimeZone = AppUtils.timeZoneForProject() {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
var calendar = Calendar.current
calendar.timeZone = projectTimeZone
return calendar.isDateInToday(Date().dateInProjectTimeZone())
}
return false
}