diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-17 07:41:58 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-17 07:41:58 +0000 |
commit | a61756e094462e6548113a7407652230f1f85161 (patch) | |
tree | 94706a5d2b7c58431c5b7750173c005671b3c356 /lib/time.rb | |
parent | 7766666aed80c7e06dfd8288302a663638b66fe5 (diff) |
merge revision(s) 49788,49790: [Backport #10904]
* lib/time.rb (strptime): Support %s.%N.
[ruby-core:68301] [Bug #10904] Patch by Sadayuki Furuhashi.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/time.rb')
-rw-r--r-- | lib/time.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/time.rb b/lib/time.rb index dd7a513dba..73a8f81177 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -393,10 +393,16 @@ class Time d = Date._strptime(date, format) raise ArgumentError, "invalid strptime format - `#{format}'" unless d if seconds = d[:seconds] + if sec_fraction = d[:sec_fraction] + usec = sec_fraction * 1000000 + usec *= -1 if seconds < 0 + else + usec = 0 + end if offset = d[:offset] - Time.at(seconds).localtime(offset) + Time.at(seconds, usec).localtime(offset) else - Time.at(seconds) + Time.at(seconds, usec) end else year = d[:year] |