aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2008-02-06 06:43:02 +0000
committerRick Olson <technoweenie@gmail.com>2008-02-06 06:43:02 +0000
commit72385a7be65bb27b07cd2ee3bc9fe221d8e04f90 (patch)
tree24e89ad3c45c6bcd41ddaa0f02d8e4918c28d51d /railties/lib
parent692dbbf79387b56e241e1acd05f74f7d71ff79a6 (diff)
downloadrails-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/lib')
-rw-r--r--railties/lib/initializer.rb16
1 files changed, 16 insertions, 0 deletions
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