ruby-changes:31112
From: akr <ko1@a...>
Date: Tue, 8 Oct 2013 06:00:21 +0900 (JST)
Subject: [ruby-changes:31112] akr:r43191 (trunk): * lib/time.rb (Time.strptime): Time.strptime('0', '%s') returns local
akr 2013-10-08 06:00:12 +0900 (Tue, 08 Oct 2013) New Revision: 43191 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43191 Log: * lib/time.rb (Time.strptime): Time.strptime('0', '%s') returns local time Time object as Ruby 2.0 and before. Modified files: trunk/ChangeLog trunk/lib/time.rb trunk/test/test_time.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43190) +++ ChangeLog (revision 43191) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Oct 8 05:58:12 2013 Tanaka Akira <akr@f...> + + * lib/time.rb (Time.strptime): Time.strptime('0', '%s') returns local + time Time object as Ruby 2.0 and before. + Tue Oct 8 05:40:37 2013 Eric Hodel <drbrain@s...> * .travis.yml: Rebuild Travis CI's "ruby-head" version on successful Index: lib/time.rb =================================================================== --- lib/time.rb (revision 43190) +++ lib/time.rb (revision 43191) @@ -393,8 +393,11 @@ class Time https://github.com/ruby/ruby/blob/trunk/lib/time.rb#L393 d = Date._strptime(date, format) raise ArgumentError, "invalid strptime format - `#{format}'" unless d if seconds = d[:seconds] - offset = d[:offset] || 0 - Time.at(seconds).localtime(offset) + if offset = d[:offset] + Time.at(seconds).localtime(offset) + else + Time.at(seconds) + end else year = d[:year] year = yield(year) if year && block_given? Index: test/test_time.rb =================================================================== --- test/test_time.rb (revision 43190) +++ test/test_time.rb (revision 43191) @@ -400,7 +400,7 @@ class TestTimeExtension < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/test_time.rb#L400 def test_strptime assert_equal(Time.utc(2005, 8, 28, 06, 54, 20), Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z")) assert_equal(Time.at(1).localtime, Time.strptime("1", "%s")) - assert_equal(0, Time.strptime('0', '%s').utc_offset) + assert_equal(false, Time.strptime('0', '%s').utc?) assert_equal(3600, Time.strptime('0 +0100', '%s %z').utc_offset) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/