Very odd time-zone behavior?

I have an ActiveRecord model which contains a timestamp field called "remember_token_expires_at". I have Time.now stubbed to return Time.parse("Jan 1, 2001"). When I do:

remember_token_expires_at = 90.days.from_now.localtime save! reload

I get the expected time in remember_token_expires_at (April 1st, midnight local time).

However, when I do:

expires_at = 90.days.from_now remember_token_expires_at = expires_at.localtime

I instead get April 1st, 5 am! Specifically, remember_token_expires_at_before_type_cast contains "2001-04-01 05:00:00".

I've looked at time.c and ActiveRecord::base.rb, and I'm stumped. I can't see how these two cases should differ. According to even their marshal data from _dump, they don't. Yet they yield different results.

What am I missing? I'm using Postgres 8.1, and I am aware of some bugs filed to support time zones, but this shouldn't be happening even without timezone support. This is just "record changes when saved and reloaded, but only if I initialize it through a temporary variable"...

Jay Levitt