I spoke incorrectly. The database is *always* UTC. However, Rails can
also maintain a concept of "local time" such that Time.now will be in
your local timezone
# You''ll probably want to change this to the time zone of the
computer where Tracks is running
# run rake time:zones:local have Rails suggest time zone names on
your system
config.time_zone = 'Pacific Time (US & Canada)'
== is apparently clever enough to do the appropriate conversions, so
wouldn't Time.now and Time#utc be equivalent for our purposes?
On Sep 16, 2008, at 11:23 AM, mathew wrote:
On Tue, Sep 16, 2008 at 8:54 AM, Eric Allen <[EMAIL PROTECTED]>
wrote:
As I'm going through the timezone stuff with a fine-toothed comb to
make sure I changed the right things, I notice a lot of uses of
TimeWithZone#utc. Why exactly do we do this? It seems to me that the
time object compares the same, and IRB agrees:
Loading development environment (Rails 2.1.0)
t = Time.now
=> Tue Sep 16 06:53:01 -0700 2008
t == t.utc
=> true
So it really shouldn't matter, right?
According to the documentation, Time.now returns the time in the local
system time zone, and Time.utc returns the time in UTC. Sure, ==
should work whichever you use, assuming == is clever enough to do the
appropriate conversions, but that doesn't mean Time.now and Time#utc
are interchangeable.
Rails translates to the
configured time zone (usually UTC) when it saves to the database.
Right, but I would say that we don't want Rails to translate to
anything other than UTC when it saves to the database, *even if* the
configured time zone is something other than UTC, because saving to
the database in anything other than UTC will result in information
loss or incorrect results because of the different ways Postgres and
MySQL handle time zones (or don't, as the case may be).
If Rails ever stores date/time values in something other than UTC in
the database, then Rails is broken in my view.
mathew
--
<URL:http://www.pobox.com/~meta/>
_______________________________________________
Tracks-discuss mailing list
[email protected]
http://lists.rousette.org.uk/mailman/listinfo/tracks-discuss
_______________________________________________
Tracks-discuss mailing list
[email protected]
http://lists.rousette.org.uk/mailman/listinfo/tracks-discuss