aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-24 12:00:42 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-24 12:00:42 +0000
commit4fbc3e30eb800d938a0dd637316fa785c402b26b (patch)
tree50df039c6bd56178d77aca62dc07a58b0f49b5a7 /activerecord/lib
parentf73f9e42f4e6987ff53e3bd5e53a5040b04f9f36 (diff)
downloadrails-4fbc3e30eb800d938a0dd637316fa785c402b26b.tar.gz
rails-4fbc3e30eb800d938a0dd637316fa785c402b26b.tar.bz2
rails-4fbc3e30eb800d938a0dd637316fa785c402b26b.zip
Changed the auto-timestamping feature to use ActiveRecord::Base.default_timezone instead of entertaining the parallel ActiveRecord::Base.timestamps_gmt method. The latter is now deprecated and will throw a warning on use (but still work) #710 [Jamis Buck]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@788 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/timestamp.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb
index 01a9720f52..c3de93d552 100644
--- a/activerecord/lib/active_record/timestamp.rb
+++ b/activerecord/lib/active_record/timestamp.rb
@@ -19,7 +19,7 @@ module ActiveRecord
end
def create_with_timestamps #:nodoc:
- t = timestamps_gmt ? Time.now.gmtime : Time.now
+ t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now )
write_attribute("created_at", t) if record_timestamps && respond_to?(:created_at) && created_at.nil?
write_attribute("created_on", t) if record_timestamps && respond_to?(:created_on) && created_on.nil?
@@ -30,7 +30,7 @@ module ActiveRecord
end
def update_with_timestamps #:nodoc:
- t = timestamps_gmt ? Time.now.gmtime : Time.now
+ t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now )
write_attribute("updated_at", t) if record_timestamps && respond_to?(:updated_at)
write_attribute("updated_on", t) if record_timestamps && respond_to?(:updated_on)
@@ -44,7 +44,17 @@ module ActiveRecord
# if the table has columns of either of these names. This feature is turned on by default.
@@record_timestamps = true
cattr_accessor :record_timestamps
+
+ # deprecated: use ActiveRecord::Base.default_timezone instead.
@@timestamps_gmt = false
- cattr_accessor :timestamps_gmt
+ def self.timestamps_gmt=( gmt ) #:nodoc:
+ warn "timestamps_gmt= is deprecated. use default_timezone= instead"
+ self.default_timezone = ( gmt ? :utc : :local )
+ end
+
+ def self.timestamps_gmt #:nodoc:
+ warn "timestamps_gmt is deprecated. use default_timezone instead"
+ self.default_timezone == :utc
+ end
end
end