aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/time.rb8
2 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2cc7f36986..5d8b46c31d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Mar 1 09:06:11 2015 Tanaka Akira <akr@fsij.org>
+
+ * lib/time.rb (strptime): Support %s.%N.
+ [ruby-core:68301] [Bug #10904] Patch by Sadayuki Furuhashi.
+
Sat Feb 28 17:18:39 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_each_slice, enum_each_cons): limit elements size by
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