aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb5
-rw-r--r--activerecord/test/migration_test.rb5
3 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 02d5be202f..c4020762dd 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* DateTimes assume the default timezone. #7764 [Geoff Buesing]
+
* Sybase: hide timestamp columns since they're inherently read-only. #7716 [Mike Joyce]
* Oracle: overflow Time to DateTime. #7718 [Michael Schoen]
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 0a9049b703..ebde8c83f4 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -118,8 +118,9 @@ module ActiveRecord
begin
Time.send(Base.default_timezone, *time_array)
rescue
- # Append zero offset to account for dates skipped by calendar reform.
- DateTime.new(*time_array[0..5] << 0 << 0) rescue nil
+ zone_offset = if Base.default_timezone == :local then DateTime.now.offset else 0 end
+ # Append zero calendar reform start to account for dates skipped by calendar reform
+ DateTime.new(*time_array[0..5] << zone_offset << 0) rescue nil
end
end
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index 3b0e310386..f5b13f6c99 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -302,7 +302,12 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal Date, bob.favorite_day.class
end
+ # Test DateTime column and defaults, including timezone.
assert_equal DateTime, bob.moment_of_truth.class
+ 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 TrueClass, bob.male?.class
assert_kind_of BigDecimal, bob.wealth
end