From 22dc11c6b17c22247b4e3d1b2b0329d9ca638da6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 1 Oct 2007 02:16:15 +0000 Subject: Fixed Date#xmlschema for dates outside the range of what can be created with Time (closes #9744) [gbuesing] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7707 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/date_ext_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activesupport/test/core_ext/date_ext_test.rb') diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 97b637f974..70f7cb0df7 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -162,4 +162,20 @@ class DateExtCalculationsTest < Test::Unit::TestCase def test_end_of_day assert_equal Time.local(2005,2,21,23,59,59), Date.new(2005,2,21).end_of_day end + + def test_xmlschema + with_timezone 'US/Eastern' do + assert_equal '1880-06-28T00:00:00-04:00', Date.new(1880, 6, 28).xmlschema + assert_equal '1980-06-28T00:00:00-04:00', Date.new(1980, 6, 28).xmlschema + assert_equal '2080-06-28T00:00:00-04:00', Date.new(2080, 6, 28).xmlschema + end + end + + protected + def with_timezone(new_tz = 'US/Eastern') + old_tz, ENV['TZ'] = ENV['TZ'], new_tz + yield + ensure + old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') + end end -- cgit v1.2.3