1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/time.rb (Time.strptime): Use :offset.

Patch by Felipe Contreras.  [ruby-core:57694]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-10-07 11:10:03 +00:00
parent 5ec7e5aae8
commit da6229a3a0
3 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Oct 7 20:07:20 2013 Tanaka Akira <akr@fsij.org>
* lib/time.rb (Time.strptime): Use :offset.
Patch by Felipe Contreras. [ruby-core:57694]
Mon Oct 7 16:47:27 2013 Koichi Sasada <ko1@atdot.net>
* test/-ext-/debug/test_profile_frames.rb: rename class C to

View file

@ -393,7 +393,8 @@ class Time
d = Date._strptime(date, format)
raise ArgumentError, "invalid strptime format - `#{format}'" unless d
if seconds = d[:seconds]
Time.at(seconds)
offset = d[:offset] || 0
Time.at(seconds).localtime(offset)
else
year = d[:year]
year = yield(year) if year && block_given?

View file

@ -400,6 +400,8 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
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(3600, Time.strptime('0 +0100', '%s %z').utc_offset)
end
def test_nsec