diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-04 07:37:11 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-04 07:37:11 +0000 |
commit | 4eb497d90b0d439458e7f34046bbe41d38e4c06a (patch) | |
tree | 7fca0af86872c6cc1450a4137f25c7d8876b0978 /lib/time.rb | |
parent | bf8168cf334e45ce6e93fa5aedc74ab7ca4069f3 (diff) | |
download | ruby-4eb497d90b0d439458e7f34046bbe41d38e4c06a.tar.gz |
* lib/time.rb (Time.strptime): use Time.at if d[:seconds] is set.
Reported by Christopher Eberz. [ruby-core:39903] Bug #5399
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/time.rb')
-rw-r--r-- | lib/time.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/time.rb b/lib/time.rb index 4eb888aef6..26c083d309 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -280,9 +280,13 @@ class Time def strptime(date, format, now=self.now) d = Date._strptime(date, format) raise ArgumentError, "invalid strptime format - `#{format}'" unless d - 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) + if seconds = d[:seconds] + 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) + end end MonthValue = { |