ruby-changes:11610
From: akr <ko1@a...>
Date: Wed, 22 Apr 2009 01:43:32 +0900 (JST)
Subject: [ruby-changes:11610] Ruby:r23247 (trunk): * time.c (time_arg): use the year argument as-is.
akr 2009-04-22 01:43:15 +0900 (Wed, 22 Apr 2009) New Revision: 23247 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23247 Log: * time.c (time_arg): use the year argument as-is. [ruby-dev:38194] * lib/time.rb (Time.parse): interpret small year 0..99 as 1950..2049. Modified files: trunk/ChangeLog trunk/NEWS trunk/lib/time.rb trunk/test/ruby/test_time.rb trunk/time.c Index: time.c =================================================================== --- time.c (revision 23246) +++ time.c (revision 23247) @@ -1398,8 +1398,6 @@ { VALUE v[8]; int i; - long year; - VALUE x; vtm->year = INT2FIX(0); vtm->mon = 0; @@ -1432,20 +1430,7 @@ vtm->isdst = -1; } - x = obj2vint(v[0]); - if (FIXNUM_P(x)) { - year = FIX2LONG(x); - if (0 <= year && year < 39) { - rb_warning("2 digits year is used: %ld", year); - year += 2000; - } - else if (69 <= year && year < 139) { - rb_warning("2 or 3 digits year is used: %ld", year); - year += 1900; - } - x = LONG2FIX(year); - } - vtm->year = x; + vtm->year = obj2vint(v[0]); if (NIL_P(v[1])) { vtm->mon = 1; Index: ChangeLog =================================================================== --- ChangeLog (revision 23246) +++ ChangeLog (revision 23247) @@ -1,3 +1,9 @@ +Wed Apr 22 01:27:38 2009 Tanaka Akira <akr@f...> + + * time.c (time_arg): use the year argument as-is. [ruby-dev:38194] + + * lib/time.rb (Time.parse): interpret small year 0..99 as 1950..2049. + Wed Apr 22 00:32:16 2009 Nobuyoshi Nakada <nobu@r...> * time.c (find_time_t): constified. Index: lib/time.rb =================================================================== --- lib/time.rb (revision 23246) +++ lib/time.rb (revision 23247) @@ -258,7 +258,21 @@ raise ArgumentError, "no time information in #{date.inspect}" end year = d[:year] - year = yield(year) if year && block_given? + if year + if block_given? + year = yield(year) + else + year = if year < 0 + year + elsif year < 50 + 2000 + year + elsif year < 100 + 1900 + year + else + year + end + end + end make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now) end Index: NEWS =================================================================== --- NEWS (revision 23246) +++ NEWS (revision 23247) @@ -52,6 +52,11 @@ * time_t restriction is removed to represent before 1901 and after 2038. Proleptic Gregorian calendar is used for old dates. + * incompatible changes: + * The year argument of Time.{utc,gm,local,mktime} is now interpreted as + the value itself. For example, Time.utc(99) means the year 99 AD, + not 1999 AD. + * Kernel * extended methods: * respond_to? returns false for methods which simply raise Index: test/ruby/test_time.rb =================================================================== --- test/ruby/test_time.rb (revision 23246) +++ test/ruby/test_time.rb (revision 23247) @@ -219,8 +219,6 @@ def test_utc_or_local assert_equal(T2000, Time.gm(2000)) assert_equal(T2000, Time.gm(0, 0, 0, 1, 1, 2000, :foo, :bar, false, :baz)) - assert_equal(T2000, Time.gm(0)) - assert_equal(T2000, Time.gm(100)) assert_equal(T2000, Time.gm(2000, "jan")) assert_equal(T2000, Time.gm(2000, "1")) assert_equal(T2000, Time.gm(2000, 1, 1, 0, 0, 0, 0)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/