aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/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/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/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index c9e9d5cbc4..e7cd550ad6 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -503,13 +503,15 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal "20050221174430123456789", time.to_s(:nsec)
assert_equal "February 21, 2005 17:44", time.to_s(:long)
assert_equal "February 21st, 2005 17:44", time.to_s(:long_ordinal)
- assert_equal "2009-02-05T14:30:05Z", Time.local(2009, 2, 5, 14, 30, 5).to_s(:iso8601)
with_env_tz "UTC" do
assert_equal "Mon, 21 Feb 2005 17:44:30 +0000", time.to_s(:rfc822)
end
with_env_tz "US/Central" do
assert_equal "Thu, 05 Feb 2009 14:30:05 -0600", Time.local(2009, 2, 5, 14, 30, 5).to_s(:rfc822)
assert_equal "Mon, 09 Jun 2008 04:05:01 -0500", Time.local(2008, 6, 9, 4, 5, 1).to_s(:rfc822)
+ assert_equal "2009-02-05T14:30:05-06:00", Time.local(2009, 2, 5, 14, 30, 5).to_s(:iso8601)
+ assert_equal "2008-06-09T04:05:01-05:00", Time.local(2008, 6, 9, 4, 5, 1).to_s(:iso8601)
+ assert_equal "2009-02-05T14:30:05Z", Time.utc(2009, 2, 5, 14, 30, 5).to_s(:iso8601)
end
end