[前][次][番号順一覧][スレッド一覧]

ruby-changes:37708

From: akr <ko1@a...>
Date: Sun, 1 Mar 2015 09:13:08 +0900 (JST)
Subject: [ruby-changes:37708] akr:r49788 (trunk): * lib/time.rb (strptime): Support %s.%N.

akr	2015-03-01 09:12:48 +0900 (Sun, 01 Mar 2015)

  New Revision: 49788

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49788

  Log:
    * lib/time.rb (strptime): Support %s.%N.
      [ruby-core:68301] [Bug #10904] Patch by Sadayuki Furuhashi.

  Modified files:
    trunk/ChangeLog
    trunk/lib/time.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49787)
+++ ChangeLog	(revision 49788)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar  1 09:06:11 2015  Tanaka Akira  <akr@f...>
+
+	* 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@r...>
 
 	* enum.c (enum_each_slice, enum_each_cons): limit elements size by
Index: lib/time.rb
===================================================================
--- lib/time.rb	(revision 49787)
+++ lib/time.rb	(revision 49788)
@@ -426,7 +426,13 @@ class Time https://github.com/ruby/ruby/blob/trunk/lib/time.rb#L426
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]