Skip to content
Browse files

DateTimes assume the default timezone. Closes #7764.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6359 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent c59bce8 commit 866cba7bb73dcd9d9ae60e8163655295d825dc58 @jeremy jeremy committed
View
2 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]
View
5 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -118,8 +118,9 @@ def self.string_to_time(string)
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
View
5 activerecord/test/migration_test.rb
@@ -302,7 +302,12 @@ def test_native_types
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

0 comments on commit 866cba7

Please sign in to comment.
Something went wrong with that request. Please try again.