aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2010-01-03 21:55:48 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2010-01-03 21:55:48 -0500
commit0422314b29e6b59362eb1111c983740784428b73 (patch)
tree2d2e9b027f7f9d13a67ca9920a61aa40a7e51b19
parent51460b5bf296d7f262f8d865f6f6f1d44513c6d4 (diff)
downloadrails-0422314b29e6b59362eb1111c983740784428b73.tar.gz
rails-0422314b29e6b59362eb1111c983740784428b73.tar.bz2
rails-0422314b29e6b59362eb1111c983740784428b73.zip
Time zoning should be turned on by default with UTC
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/rails/application.rb18
-rw-r--r--railties/lib/rails/configuration.rb4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/application.rb7
4 files changed, 17 insertions, 14 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 0bc1ea32bc..4e61479fb3 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Set config.time_zone to UTC by default [DHH]
+
* Added default .gitignore (this is just recognizing Git market share, don't throw a hissy if you use another SCM) [DHH]
* Added cookies.permanent, cookies.signed, and cookies.permanent.signed accessor for common cookie actions [DHH]. Examples:
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 457eef648c..5e68c05d7c 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -207,18 +207,16 @@ module Rails
# Sets the default value for Time.zone
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
initializer :initialize_time_zone do
- if config.time_zone
- require 'active_support/core_ext/time/zones'
- zone_default = Time.__send__(:get_zone, config.time_zone)
-
- unless zone_default
- raise \
- 'Value assigned to config.time_zone not recognized.' +
- 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.'
- end
+ require 'active_support/core_ext/time/zones'
+ zone_default = Time.__send__(:get_zone, config.time_zone)
- Time.zone_default = zone_default
+ unless zone_default
+ raise \
+ 'Value assigned to config.time_zone not recognized.' +
+ 'Run "rake -D time" for a list of tasks for finding appropriate time zone names.'
end
+
+ Time.zone_default = zone_default
end
# Set the i18n configuration from config.i18n but special-case for the load_path which should be
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index f0a0d5e55e..7c1d549c9a 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -230,6 +230,10 @@ module Rails
def log_level
@log_level ||= RAILS_ENV == 'production' ? :info : :debug
end
+
+ def time_zone
+ @time_zone ||= "UTC"
+ end
def i18n
@i18n ||= begin
diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb
index ec0729db04..b6c1cef8cd 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -17,15 +17,14 @@ module <%= app_name.classify %>
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names.
- config.time_zone = 'UTC'
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
- # Configure generators values. Many other options are available, be sure to
- # check the documentation.
+ # Configure generators values. Many other options are available, be sure to check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb