Created
June 3, 2014 02:11
-
-
Save plexus/c17b0fe87fa9e010b09b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There is some interesting magic going on regarding time zones in Rails, even more | |
# so in Rails 3. The easiest is to talk in UTC to your database and any other service | |
# you might consume, but we're stuck with a legacy schema that stores Irish time | |
# without time zone information. | |
# | |
# With these settings, ActiveRecord assumes that what is in your DB is in local time, | |
# and the local time zone is configured to be Dublin, i.e. IST (Irish summer time) | |
# in summer, UTC (in Ruby still referred to as GMT) in winter. | |
# When writing to the DB times will first be converted it to Irish time (if it's not already). | |
# When reading no conversion happens but the time zone is set as being IST/GMT. | |
# | |
# Methods such as Time.now will return the current time _in Ireland_. So if your | |
# machine is in CET they will be one hour earlier, but they will be correct because | |
# their time zone is also set to IST/GMT. And because their time zone is IST/GMT | |
# they will be written to the DB without conversion. | |
# | |
# One caveat : Time.utc and similar methods will return the actual UTC time, which | |
# is usually not what you want, so use Time.new instead. | |
# | |
# http://databasically.com/2010/10/22/what-time-is-it-or-handling-timezones-in-rails/ | |
# http://www.elabs.se/blog/36-working-with-time-zones-in-ruby-on-rails | |
# http://ianlotinsky.wordpress.com/2012/08/25/time-zones-ruby-on-rails-and-mysql/ | |
# http://zerowidth.com/2011/04/20/fixing-timezones-in-rails-2.html | |
ENV["TZ"]="Europe/Dublin" | |
config.time_zone = "Dublin" | |
config.active_record.default_timezone = :local | |
ActiveRecord::Base.time_zone_aware_attributes = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment