Fix to SYNTAX-PARSE-ISO-8601 to parse fractions of seconds
authorKevin Rosenberg <kevin@rosenberg.net>
Thu, 10 Dec 2009 14:15:30 +0000 (07:15 -0700)
committerKevin Rosenberg <kevin@rosenberg.net>
Thu, 10 Dec 2009 14:15:30 +0000 (07:15 -0700)
ChangeLog
sql/time.lisp

index a741db9a0f25a3894c1ed5c2ef20fb64b41ba8cb..4e59172f54790550fcafa8f1d8a85e996237b2e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+10 Dec 2009  Kevin Rosenberg <kevin@rosenberg.net>
+       * sql/time.lisp: Patch from Oleg Tihonov to SYNTAX-PARSE-ISO-8601
+       to properly parse fractions of seconds.
+
 10 Dec 2009  Kevin Rosenberg <kevin@rosenberg.net>
        * sql/time.lisp: Patch from Oleg Tihonov to roll function
        to properly use USEC argument.
index 554bc17984fa5c1931706b632eb8eaf8dcb3b079..66731c13531f8e12f6eadf8963ec5a21cb67b2a8 100644 (file)
@@ -1315,16 +1315,18 @@ Will throw a hissy fit if the date string is a duration. Will ignore any precisi
                       (char= #\. (char string 19))))
              (multiple-value-bind (parsed-usec usec-end)
                  (parse-integer string :start 20 :junk-allowed t)
-               (setf usec          (or parsed-usec 0)
-                     gmt-sec-offset (if (<= (+ 3 usec-end)  strlen)
-                                        (let ((skip-to (or (position #\+ string :start 19)
-                                                           (position #\- string :start 19))))
-                                          (if skip-to
-                                              (* 60 60
-                                                 (parse-integer string :start skip-to
-                                                                :end (+ skip-to 3)))
-                                              0))
-                                        0))))
+               (let ((parsed-usec (and parsed-usec
+                                      (floor (* parsed-usec (expt 10 (+ 6 (- usec-end) 20)))))))
+                (setf usec          (or parsed-usec 0)
+                      gmt-sec-offset (if (<= (+ 3 usec-end)  strlen)
+                                         (let ((skip-to (or (position #\+ string :start 19)
+                                                            (position #\- string :start 19))))
+                                           (if skip-to
+                                               (* 60 60
+                                                  (parse-integer string :start skip-to
+                                                                 :end (+ skip-to 3)))
+                                               0))
+                                         0)))))
             (t
              (setf usec           0
                    gmt-sec-offset (if (<= 22  strlen)