mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/time.rb (Time.strptime): Use d[:offset] if d[:seconds] is not
given. Reported by tadayoshi funaba. [ruby-core:62322] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
38656e24be
commit
4de238663a
3 changed files with 13 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
Sat May 3 20:21:38 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lib/time.rb (Time.strptime): Use d[:offset] if d[:seconds] is not
|
||||
given.
|
||||
Reported by tadayoshi funaba. [ruby-core:62322]
|
||||
|
||||
Sat May 3 04:04:16 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END
|
||||
|
|
12
lib/time.rb
12
lib/time.rb
|
@ -393,16 +393,16 @@ class Time
|
|||
d = Date._strptime(date, format)
|
||||
raise ArgumentError, "invalid strptime format - `#{format}'" unless d
|
||||
if seconds = d[:seconds]
|
||||
if offset = d[:offset]
|
||||
Time.at(seconds).localtime(offset)
|
||||
else
|
||||
Time.at(seconds)
|
||||
end
|
||||
t = Time.at(seconds)
|
||||
else
|
||||
year = d[:year]
|
||||
year = yield(year) if year && block_given?
|
||||
make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
|
||||
t = make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
|
||||
end
|
||||
if offset = d[:offset]
|
||||
t.localtime(offset)
|
||||
end
|
||||
t
|
||||
end
|
||||
|
||||
MonthValue = { # :nodoc:
|
||||
|
|
|
@ -402,6 +402,7 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
|||
assert_equal(Time.at(1).localtime, Time.strptime("1", "%s"))
|
||||
assert_equal(false, Time.strptime('0', '%s').utc?)
|
||||
assert_equal(3600, Time.strptime('0 +0100', '%s %z').utc_offset)
|
||||
assert_equal(-7200, Time.strptime('20010203 -0200', '%Y%m%d %z').utc_offset)
|
||||
end
|
||||
|
||||
def test_nsec
|
||||
|
|
Loading…
Reference in a new issue