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.
on 2009-01-29 15:13
on 2009-01-29 16:07
On Thu, Jan 29, 2009 at 3:11 PM, stephen O'D <email@example.com>wrote: > savings and these recurring reminders and people changing their > > > Opinions, comments and best practices all appreciated! > > Thanks, > > Stephen. > > > I haven't worked with time zones yet but a quick search returned this http://mad.ly/2008/04/09/rails-21-time-zone-suppor... which has some mentions of daylight savings. -- Andrew T. http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain
on 2009-01-29 17:00
> > I haven't worked with time zones yet but a quick search returned thishttp://mad.ly/2008/04/09/rails-21-time-zone-suppor... has > some mentions of daylight savings. > Yea I have been through one. Its helps with one off events, but not recurring ones or if someone needs to change their timezone, which pretty much turns it all on its head. I am hoping someone has some experience of what I want to do and can share some lessons learned or tricks they used.