Ruby on Rails Monday, May 31, 2010

I am struggling with time zone support in Rails 3 beta and I would
like to know if it is a bug or if I am doing something wrong. He is
the problem:

> Time.zone = 'Madrid' # it is GMT+2
=> "Madrid"
> c = Comment.new
=> #<Comment id: nil, title: "", pub_at: nil>
> c.pub_at = Time.zone.parse('10:00:00')
=> Mon, 31 May 2010 10:00:00 CEST +02:00
> c.save
> c
=> #&lt;Comment id: 3, title: "", pub_at: "2010-05-31 08:00:00">
> c.reload
=> #&lt;Comment id: 3, title: "", pub_at: "2010-05-31 08:00:00">
ruby-1.8.7-p249 > c.pub_at
=> Mon, 31 May 2010 13:00:00 CEST +02:00

As you can see, the pub_at attribute is stored correctly in the
database but when it is retrieved it adds 3 hours and I suspect that
it is because it is using my local machine timezone that is in GMT-3.

The same sequence of commands in rails 2.3.5 works perfectly.

Any toughts? Should I report a ticket?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment