aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2007-11-24 04:59:21 +0000
committerGeoff Buesing <gbuesing@gmail.com>2007-11-24 04:59:21 +0000
commitbecdb49186c575bf96a82a949ac04b6078680d52 (patch)
tree48c91b2df8feba4a7e6795c161a2e92970bc323c /activerecord
parentd84846a636fbc180b3d6fcf52aa8559e1b7bb960 (diff)
downloadrails-becdb49186c575bf96a82a949ac04b6078680d52.tar.gz
rails-becdb49186c575bf96a82a949ac04b6078680d52.tar.bz2
rails-becdb49186c575bf96a82a949ac04b6078680d52.zip
Honor Ruby's default calendar reform setting when creating DateTime objects via ActiveRecord's Time -> DateTime overflow, Time#time_with_datetime_fallback, Time#to_datetime, Date#to_datetime and String#to_datetime. Closes #10201
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8199 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb3
-rw-r--r--activerecord/test/migration_test.rb3
3 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index a8146ab460..687aed9874 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* DateTimes use Ruby's default calendar reform setting. #10201 [Geoff Buesing]
+
* Dynamic finders on association collections respect association :order and :limit. #10211, #10227 [Patrick Joyce, Rick Olson, Jack Danger Canty]
* Add 'foxy' support for fixtures of polymorphic associations. #10183 [jbarnette, David Lowenfels]
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index c6cdc776d6..39064d4d13 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -174,8 +174,7 @@ module ActiveRecord
# Over/underflow to DateTime
rescue ArgumentError, TypeError
zone_offset = Base.default_timezone == :local ? DateTime.local_offset : 0
- # Append zero calendar reform start to account for dates skipped by calendar reform
- DateTime.new(year, mon, mday, hour, min, sec, zone_offset, 0) rescue nil
+ DateTime.civil(year, mon, mday, hour, min, sec, zone_offset) rescue nil
end
def fast_string_to_date(string)
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index 00081dca56..64b8d51f39 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -286,7 +286,7 @@ if ActiveRecord::Base.connection.supports_migrations?
:bio => "I was born ....", :age => 18, :height => 1.78,
:wealth => BigDecimal.new("12345678901234567890.0123456789"),
:birthday => 18.years.ago, :favorite_day => 10.days.ago,
- :moment_of_truth => "1582-10-10 21:40:18", :male => true
+ :moment_of_truth => "1782-10-10 21:40:18", :male => true
end
bob = Person.find(:first)
@@ -323,6 +323,7 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal DateTime.now.offset, bob.moment_of_truth.offset
assert_not_equal 0, bob.moment_of_truth.offset
assert_not_equal "Z", bob.moment_of_truth.zone
+ assert_equal DateTime::ITALY, bob.moment_of_truth.start
end
assert_equal TrueClass, bob.male?.class