summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-09 13:19:32 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-09 13:19:32 +0000
commit855c6b4507ec3906b1d3e2e817f5c2f3819c83d5 (patch)
treec662f75548eecb72044ab808b3bcf307d174eced /lib
parent341d9e5858024f290e8e749aef1fc79c79b2747b (diff)
merges r33398 from trunk into ruby_1_9_3.
-- * 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/branches/ruby_1_9_3@33444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/time.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/time.rb b/lib/time.rb
index ffccdeca5e..1663af8e76 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -281,9 +281,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 = {