aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/date_time_ext_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-07-29 12:28:19 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2013-07-29 12:31:20 +0100
commit88c0ef4d4fc86faefeec5bfff87ad882f62468d8 (patch)
tree395cf236c5bb23795dcffb613cdc7721b3da1554 /activesupport/test/core_ext/date_time_ext_test.rb
parentcde979c38832b99d8c85b5f44f7357931ade1ee0 (diff)
downloadrails-88c0ef4d4fc86faefeec5bfff87ad882f62468d8.tar.gz
rails-88c0ef4d4fc86faefeec5bfff87ad882f62468d8.tar.bz2
rails-88c0ef4d4fc86faefeec5bfff87ad882f62468d8.zip
Fix handling of offsets with Time#to_s(:iso8601)
Use a lambda to ensure that the generated string respects the offset of the time value. Also add DateTime#to_s(:iso8601) and Date#to_s(:iso8601) for completeness.
Diffstat (limited to 'activesupport/test/core_ext/date_time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/date_time_ext_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb
index 571344b728..5e9b3601ff 100644
--- a/activesupport/test/core_ext/date_time_ext_test.rb
+++ b/activesupport/test/core_ext/date_time_ext_test.rb
@@ -18,6 +18,12 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal "Mon, 21 Feb 2005 14:30:00 +0000", datetime.to_s(:rfc822)
assert_equal "February 21st, 2005 14:30", datetime.to_s(:long_ordinal)
assert_match(/^2005-02-21T14:30:00(Z|\+00:00)$/, datetime.to_s)
+
+ with_env_tz "US/Central" do
+ assert_equal "2009-02-05T14:30:05-06:00", DateTime.civil(2009, 2, 5, 14, 30, 5, Rational(-21600, 86400)).to_s(:iso8601)
+ assert_equal "2008-06-09T04:05:01-05:00", DateTime.civil(2008, 6, 9, 4, 5, 1, Rational(-18000, 86400)).to_s(:iso8601)
+ assert_equal "2009-02-05T14:30:05+00:00", DateTime.civil(2009, 2, 5, 14, 30, 5).to_s(:iso8601)
+ end
end
def test_readable_inspect