Welcome to ClipClip!
Already a Member? Sign In
 

the { buckblogs :here }: Introducing TzTime

source: http://weblog.jamisbuck.org/2007/2/2/introducing-tztime

clipped by chao Feb 03, 2007

develop a ruby on rails web app

Chao

Notes by chao:

Wow, a plugin to deal with timezones!

  • 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_id to 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.

 

Comments

No comments yet

Please sign in to comment.