public
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/NZKoz/koz-rails.git
Search Repo:
TimeWithZone: Adding tests for dst and leap day edge cases when advancing 
time

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9213 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
gbuesing (author)
Wed Apr 02 07:15:30 -0700 2008
commit  7a0e06d7033dd4d3c00a0622b23d2cdb64f497c7
tree    cf7c5c829113bc0fab875c6fed5541958c7dab27
parent  3baa1d09da8d24565d9c45f46366baeec7086cb5
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* TimeWithZone: Adding tests for dst and leap day edge cases when advancing time [Geoff Buesing]
0
+
0
 * TimeWithZone#method_missing: send to utc to advance with dst correctness, otherwise send to time. Adding tests for time calculations methods [Geoff Buesing]
0
 
0
 * Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]
...
456
457
458
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
460
461
...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
0
@@ -456,6 +456,41 @@ class TimeWithZoneTest < Test::Unit::TestCase
0
   def test_seconds_since_midnight
0
     assert_equal 19 * 60 * 60, @twz.seconds_since_midnight
0
   end
0
+
0
+ def test_advance_1_year_from_leap_day
0
+ twz = ActiveSupport::TimeWithZone.new(nil, @time_zone, Time.utc(2004,2,29))
0
+ assert_equal "Mon, 28 Feb 2005 00:00:00 EST -05:00", twz.advance(:years => 1).inspect
0
+ assert_equal "Mon, 28 Feb 2005 00:00:00 EST -05:00", twz.years_since(1).inspect
0
+ assert_equal "Mon, 28 Feb 2005 00:00:00 EST -05:00", (twz + 1.year).inspect
0
+ end
0
+
0
+ def test_advance_1_month_from_last_day_of_january
0
+ twz = ActiveSupport::TimeWithZone.new(nil, @time_zone, Time.utc(2005,1,31))
0
+ assert_equal "Mon, 28 Feb 2005 00:00:00 EST -05:00", twz.advance(:months => 1).inspect
0
+ assert_equal "Mon, 28 Feb 2005 00:00:00 EST -05:00", twz.months_since(1).inspect
0
+ assert_equal "Mon, 28 Feb 2005 00:00:00 EST -05:00", (twz + 1.month).inspect
0
+ end
0
+
0
+ def test_advance_1_month_from_last_day_of_january_during_leap_year
0
+ twz = ActiveSupport::TimeWithZone.new(nil, @time_zone, Time.utc(2000,1,31))
0
+ assert_equal "Tue, 29 Feb 2000 00:00:00 EST -05:00", twz.advance(:months => 1).inspect
0
+ assert_equal "Tue, 29 Feb 2000 00:00:00 EST -05:00", twz.months_since(1).inspect
0
+ assert_equal "Tue, 29 Feb 2000 00:00:00 EST -05:00", (twz + 1.month).inspect
0
+ end
0
+
0
+ def test_advance_1_month_into_spring_dst_gap
0
+ twz = ActiveSupport::TimeWithZone.new(nil, @time_zone, Time.utc(2006,3,2,2))
0
+ assert_equal "Sun, 02 Apr 2006 03:00:00 EDT -04:00", twz.advance(:months => 1).inspect
0
+ assert_equal "Sun, 02 Apr 2006 03:00:00 EDT -04:00", twz.months_since(1).inspect
0
+ assert_equal "Sun, 02 Apr 2006 03:00:00 EDT -04:00", (twz + 1.month).inspect
0
+ end
0
+
0
+ def test_advance_1_second_into_spring_dst_gap
0
+ twz = ActiveSupport::TimeWithZone.new(nil, @time_zone, Time.utc(2006,4,2,1,59,59))
0
+ assert_equal "Sun, 02 Apr 2006 03:00:00 EDT -04:00", twz.advance(:seconds => 1).inspect
0
+ assert_equal "Sun, 02 Apr 2006 03:00:00 EDT -04:00", (twz + 1).inspect
0
+ assert_equal "Sun, 02 Apr 2006 03:00:00 EDT -04:00", (twz + 1.second).inspect
0
+ end
0
 end
0
 
0
 class TimeWithZoneMethodsForTimeAndDateTimeTest < Test::Unit::TestCase

Comments

    No one has commented yet.