From c81a9fe27ee259429b89ef680788abb8f8e1b26a Mon Sep 17 00:00:00 2001 From: Kevin Rosenberg Date: Thu, 10 Dec 2009 07:15:30 -0700 Subject: [PATCH] Fix to SYNTAX-PARSE-ISO-8601 to parse fractions of seconds --- ChangeLog | 4 ++++ sql/time.lisp | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index a741db9..4e59172 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +10 Dec 2009 Kevin Rosenberg + * sql/time.lisp: Patch from Oleg Tihonov to SYNTAX-PARSE-ISO-8601 + to properly parse fractions of seconds. + 10 Dec 2009 Kevin Rosenberg * sql/time.lisp: Patch from Oleg Tihonov to roll function to properly use USEC argument. diff --git a/sql/time.lisp b/sql/time.lisp index 554bc17..66731c1 100644 --- a/sql/time.lisp +++ b/sql/time.lisp @@ -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) -- 2.34.1