diff options
author | Rick Olson <technoweenie@gmail.com> | 2008-02-06 06:43:02 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2008-02-06 06:43:02 +0000 |
commit | 72385a7be65bb27b07cd2ee3bc9fe221d8e04f90 (patch) | |
tree | 24e89ad3c45c6bcd41ddaa0f02d8e4918c28d51d /railties | |
parent | 692dbbf79387b56e241e1acd05f74f7d71ff79a6 (diff) | |
download | rails-72385a7be65bb27b07cd2ee3bc9fe221d8e04f90.tar.gz rails-72385a7be65bb27b07cd2ee3bc9fe221d8e04f90.tar.bz2 rails-72385a7be65bb27b07cd2ee3bc9fe221d8e04f90.zip |
Add Time Zone support to ActiveRecord, and config.time_zone property for specifying a default Time Zone. Closes #10982 [Geoff Buesing, rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8806 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index e4a0a98d37..1e1f328837 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add config.time_zone for configuring the default Time.zone value. #10982 [Geoff Buesing] + * Reshuffle load order so that routes and observers are initialized after plugins and app initializers. Closes #10980 [rick] * Git support for script/generate. #10690 [ssoroka] diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 4e94b850d8..d839415e49 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -81,6 +81,7 @@ module Rails initialize_dependency_mechanism initialize_whiny_nils initialize_temporary_session_directory + initialize_time_zone initialize_framework_settings add_support_load_paths @@ -316,6 +317,16 @@ module Rails end end + def initialize_time_zone + if configuration.time_zone + Time.zone_default = TimeZone[configuration.time_zone] + if configuration.frameworks.include?(:active_record) + ActiveRecord::Base.time_zone_aware_attributes = true + ActiveRecord::Base.default_timezone = :utc + end + end + end + # Initializes framework-specific settings for each of the loaded frameworks # (Configuration#frameworks). The available settings map to the accessors # on each of the corresponding Base classes. @@ -456,6 +467,11 @@ module Rails end alias_method :breakpoint_server=, :breakpoint_server + # Sets the default time_zone. Setting this will enable time_zone + # awareness for ActiveRecord models and set the ActiveRecord default + # timezone to :utc. + attr_accessor :time_zone + # Create a new Configuration instance, initialized with the default # values. def initialize |