Forum: Ruby on Rails Time.parse and some weird defassage with timezone

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andres Paglayan (Guest)
on 2009-02-24 18:02
(Received via mailing list)
Hi,

I have a strange case,
my system clock is set to utc and eastern time (-5)

rails is configured to use eastern time

timestamps on the database work as expected,
meaning they are stored in utc

but by hand time entries are 2 hours behind, (why on earth two?)

i.e
Time.parse("2008-02-24 4 pm") will return Tue Feb 24 16:00:00 -0500 2009
but will store it in the database as 19:00 instead of 21:00 hrs (utc
speaking)


Any clues?
Maurício L. (Guest)
on 2009-02-24 18:50
(Received via mailing list)
What happens if you do this:

puts( Time.parse("2008-02-24 4 pm").utc )

Do you get the correct UTC time?

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
Andres (Guest)
on 2009-03-23 03:54
(Received via mailing list)
On Feb 24, 10:49 am, Maurício Linhares <removed_email_address@domain.invalid>
wrote:
> What happens if you do this:
>
> puts( Time.parse("2008-02-24 4 pm").utc )
>
> Do you get the correct UTC time?
>
Brigado Mauricio for the replay, yep,
this was on scraped data, ashamed to say that I wasn't checking its
integrity,
when i got the data like this: yyyy-mm-ddhh_mm (without space between
dd and hh),
interestingly enough, after 2,200 parses the parser starts the 2 hour
drift,
(I am making sure that the date string comes properly formatted now)
but still, an interesting 'feature'
This topic is locked and can not be replied to.