This project is archived and is in readonly mode.
Time columns don't handle timezone correctly
Reported by Andrew Vit | September 22nd, 2008 @ 10:50 PM | in 2.x
When saving to a :time column, the value is converted to the database timezone (expect UTC in a normal setting).
When reading the value back from the database, the time value has no timezone (since time fields don't store this information) and the value is read back verbatim, and thus shifted.
I'm working around this with the following accessor:
def mon_open
self[mon_open] && self[mon_open].in_time_zone
end
Comments and changes to this ticket
-
Rick September 23rd, 2008 @ 12:17 AM
- State changed from new to open
Try turning #time_zone_aware_attributes on in config/initializers.
ActiveRecord::Base.time_zone_aware_attributes = true
-
Geoff Buesing September 23rd, 2008 @ 02:07 AM
If this shift is happening via multiparameter attributes, this commit fixes it:
http://github.com/rails/rails/co...
(it's been commited to both master and 2-1-stable)
Let us know if this fixes the issue for you.
-
Andrew Vit September 23rd, 2008 @ 07:12 AM
Thanks guys, looks like it's fixed in edge. Burn this ticket!
-
josh December 20th, 2008 @ 05:27 PM
- State changed from open to resolved
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>
People watching this ticket
Tags
Referenced by
- 2527 Time columns are not zone aware #1095 seems to be the same issue.