Introducing TzTime
Posted by Jamis on February 02, 2007 @ 01:52 PM
Time zones were created specifically to make programmers’ lives miserable. I’ve been tasked at least three times now to retrofit time zones into an application, and each time has been painful.
Traditionally, I’ve done time zones as follows:
- Install the tzinfo gem
- Install the tzinfo_timezone rails plugin
- Add a
time_zone_idto the accounts (or users) table - Set ActiveRecord::Base.default_time_zone to :utc
- Define user2utc and utc2user helpers (for converting times between the user’s time zone and UTC)
- Search through the code and find every place that either
displays a date/time (
strftime, etc.) or stores a user-entered time in the database, and make liberal use of user2utc and utc2user
What. A. Pain.

Loading...
Notes by chao:
Wow, a plugin to deal with timezones!