Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Time columns don't handle timezone correctly

#1095

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

Reported by Andrew Vit · September 22nd, 2008 @ 10:50 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Rick
    Rick
    • State changed from new to open

    Try turning #time_zone_aware_attributes on in config/initializers.

    ActiveRecord::Base.time_zone_aware_attributes = true
    
    

    September 23rd, 2008 @ 12:17 AM

  2. Geoff Buesing
    Geoff Buesing

    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.

    September 23rd, 2008 @ 02:07 AM

  3. Andrew Vit
    Andrew Vit

    Thanks guys, looks like it's fixed in edge. Burn this ticket!

    September 23rd, 2008 @ 07:12 AM

  4. josh
    josh
    • State changed from open to resolved

    December 20th, 2008 @ 05:27 PM