This project is archived and is in readonly mode.
Time - TimeWithZone fails (sometimes)
Reported by Sai Emrys | October 22nd, 2009 @ 07:28 AM
38 :> x = Time.zone.now
=> Thu, 22 Oct 2009 06:23:32 UTC 00:00
39 :> y = Time.now
=> Wed Oct 21 23:23:35 -0700 2009
40 :> x.class
=> ActiveSupport::TimeWithZone
41 :> y.class
=> Time
42 :> x - y
=> -2.95153093338013
43 :> y - x
=> 2.951531
44 :> x = Comment.last.updated_at
Comment Load (0.000331) (1 Row) SELECT * FROM `comments` WHERE (comments.deleted_at IS NULL OR comments.deleted_at > '2009-10-21 23:25:01') ORDER BY comments.id DESC LIMIT 1
=> Wed, 21 Oct 2009 23:07:29 UTC 00:00
45 :> x.class
=> ActiveSupport::TimeWithZone
46 :> x - y
=> -26166.2522480488
47 :> y - x
=> Wed Dec 31 23:16:06 -0800 1969
in environment:
config.time_zone = 'UTC'
config.active_record.default_timezone = 'Pacific Time (US & Canada)'
This is in Rails 2.3.4.
WTF?
Comments and changes to this ticket
-
Sai Emrys October 22nd, 2009 @ 07:35 AM
Removing the config.active_record.default_timezone fixes this. (I added it to try to help with #1339.)
Nevertheless, it's a weird bug.
-
Geoff Buesing October 27th, 2009 @ 02:16 AM
- State changed from new to invalid
The only valid settings for config.active_record.default_timezone are :utc and :local.
I've seen others make this same error -- they assume default_timezone can be set to any of the ActiveSupport timezone names. Might make sense to raise an exception if someone tries to do that, to help with the confusion.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>