It's generaly accepted as a good practise to store dates as UTC/GMT and convert them back to local time when they need to be displayed to the user. Working currently on calendar app I am wondering how to do this for future/past dates taking into account the current Daylight saving time.
Date to UTC:
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(abbreviation: "UTC")
let dt = dateFormatter.date(from: date)
Date back to local time:
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone.current
let dt = dateFormatter.date(from: date)
Example: When a user living in Amsterdam schedules a future meeting from 4pm to 5pm (UTC+2). I'll be storing the UTC equivalent which is 2pm to 3pm. Now if he would like check his meeting in two months when Amsterdam has passed from summer- to winter-time (UTC-1), the user will see that his meeting has shifted to 3pm - 4pm.
How would I best tackle this ?