I have an app that stores appointments.
Appointments can recur daily, weekly etc or just be one off.
The application needs to notify users 15 minutes before each
appointment.
Now, I know that I can use various Rails 2.1 features to help with
TimeZones such as Time.zones, but what I am not sure about is daylight
savings and these recurring reminders and people changing their
timezones.
Lets say a user creates a daily reminder for 1pm in their timezone,
say UTC -5 - ActiveRecord stores it at 6pm UTC.
Later in the year, due to daylight savings, their timezone becomes UTC
-4, and all of a sudden, their appointment shifts by 1 hour.
Also, if a user flies off on business, and their timezone becomes UTC
+5, all the appointments will be totally at the wrong time.
I am wondering what the best practice for this sort of scenario is?
Should I always store local times in my database (ie if a user wants
an appointment at 1pm, just store 1pm) and then the logic that sends
reminders needs to get a time and adjust it to UTC to figure out when
to send the reminder? That allows me to change reminders, and handle
daylight savings correctly, at the expense of complex reminder logic.
I struggle to think of a way of handling daylight saving around daily
appointments etc if I store appointments normalised to UTC in my
database?
Opinions, comments and best practices all appreciated!
Thanks,
Stephen.