Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is the price to pay when you "love" Black Magic frameworks. As you can see, Rails' ActiveRecord will override timezone for all time/datetime attributes up to your "rails configuration". There is nothing to do about it. This is the Rails way. Nice, huh?
2.0.0p247 :001 > e =, date_offset: 'GMT-4')
=> #<Event id: nil, start_date_time: "2013-11-01 13:03:31", date_offset: "GMT-4", created_at: nil, updated_at: nil>
2.0.0p247 :002 > e.start_date_time
=> Fri, 01 Nov 2013 11:03:31 BRST -02:00
2.0.0p247 :003 > d =
=> Fri, 01 Nov 2013 13:04:02 -0200
2.0.0p247 :004 >, d.month,, d.hour, d.minute, d.second, e.date_offset)
=> Fri, 01 Nov 2013 13:04:02 -0400

This comment has been minimized.

Copy link
Owner Author

hlegius commented Nov 1, 2013

To Railers: I am NOT trying to change the default timezone. I must define date and timezone for my own. Each Event will have a datetime and a timezone.

My target here was save the date with timezone in the start_date_time attribute, instead of saving wrong timezone and do conversions on the fly everytime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.