commit cf79ad311e6f7c382c8955ef5a8bc0e1f80e87f5 Author: Sadayuki Furuhashi Date: Wed Feb 25 17:03:46 2015 -0800 time.rb: Time.strptime with %s.%N format should not ignore sec_fraction diff --git a/lib/time.rb b/lib/time.rb index 8edc9e6..07196a3 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