Weird problem with TimeZone::adjust and TimeZone::unadjust

I’m not sure I’m understanding this correctly. I have a user model
that is for all of my user accounts. Each user account has a time
zone. I added this line to automatically create a TimeZone object for
that user using their timezone:

composed_of :tz, :class_name => ‘TimeZone’, :mapping => %w(time_zone
name)

I also changed my environment.rb to add the following:

ENV[‘TZ’] = ‘UTC’

Then when I go into the console I get bad results:

drew = User.find 1
=> #<User:0x2a96b01cf8 @attributes={“time_zone”=>“Central Time (US &
Canada)”}>

Time.now
=> Mon Jul 17 15:56:54 UTC 2006

‘I am in central time and the current time is 12:04 pm’
=> “I am in central time and the current time is 12:04 pm”

drew.tz.adjust(Time.now)
=> Mon Jul 17 09:57:40 UTC 2006

drew.tz.unadjust(Time.now)
=> Mon Jul 17 21:57:55 UTC 2006

None of the above say 12:04pm, which was the time when I ran this
script. I am in central time and the time_zone for this user is
central time as well.

What am I doing wrong here? Thanks a lot for your help.

Thank You,
Ben J.
E: [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs