From 0422314b29e6b59362eb1111c983740784428b73 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 21:55:48 -0500 Subject: Time zoning should be turned on by default with UTC --- railties/lib/rails/application.rb | 18 ++++++++---------- railties/lib/rails/configuration.rb | 4 ++++ .../rails/app/templates/config/application.rb | 7 +++---- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'railties/lib') 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 -- cgit v1.2.3