Skip to content

Commit

Permalink
Time zoning should be turned on by default with UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Jan 4, 2010
1 parent 51460b5 commit 0422314
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions railties/CHANGELOG
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
18 changes: 8 additions & 10 deletions railties/lib/rails/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,16 @@ def call(env)
# 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
Expand Down
4 changes: 4 additions & 0 deletions railties/lib/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def log_path
def log_level
@log_level ||= RAILS_ENV == 'production' ? :info : :debug
end

def time_zone
@time_zone ||= "UTC"
end

def i18n
@i18n ||= begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ class Application < Rails::Application
# 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
Expand Down

0 comments on commit 0422314

Please sign in to comment.