From 9ee9812dad9c59c0638d52325546e01a40904d10 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 1 Mar 2015 00:12:48 +0000 Subject: * 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/trunk@49788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/time.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/time.rb b/lib/time.rb index 8edc9e63c3..07196a3c23 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -426,7 +426,13 @@ class Time d = Date._strptime(date, format) raise ArgumentError, "invalid strptime format - `#{format}'" unless d if seconds = d[:seconds] - t = Time.at(seconds) + if sec_fraction = d[:sec_fraction] + usec = sec_fraction * 1000000 + usec *= -1 if seconds < 0 + else + usec = 0 + end + t = Time.at(seconds, usec) if zone = d[:zone] force_zone!(t, zone) end -- cgit v1.2.3