projects
/
clsql.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fe35407
)
made parse-time/datestring handle already parsed time/datestrings
author
Russ Tyndall
<russ@acceleration.net>
Fri, 17 Jun 2011 19:47:27 +0000
(15:47 -0400)
committer
Nathan Bird
<nathan@acceleration.net>
Mon, 20 Jun 2011 20:06:17 +0000
(16:06 -0400)
sql/time.lisp
patch
|
blob
|
history
diff --git
a/sql/time.lisp
b/sql/time.lisp
index 83e17a0a121436c65f5ee8fef17681de75ba6d88..0bb18c340b45aad6aaaec43ab4cc3172739b397c 100644
(file)
--- a/
sql/time.lisp
+++ b/
sql/time.lisp
@@
-1189,17
+1189,28
@@
rules"
timestring starts with P, read a duration; otherwise read an ISO 8601
formatted date string."
(declare (ignore junk-allowed))
timestring starts with P, read a duration; otherwise read an ISO 8601
formatted date string."
(declare (ignore junk-allowed))
- (let ((string (subseq timestring start end)))
- (if (char= (aref string 0) #\P)
- (parse-iso-8601-duration string)
- (parse-iso-8601-time string))))
+ (etypecase timestring
+ (wall-time timestring)
+ (date (date->time timestring))
+ (string
+ (let ((string (subseq timestring start end)))
+ (if (char= (aref string 0) #\P)
+ (parse-iso-8601-duration string)
+ (parse-iso-8601-time string))))))
(defun parse-datestring (datestring &key (start 0) end junk-allowed)
"parse a ISO 8601 timestring and return the corresponding date.
Will throw a hissy fit if the date string is a duration. Will ignore any precision beyond day (hour/min/sec/usec)."
(defun parse-datestring (datestring &key (start 0) end junk-allowed)
"parse a ISO 8601 timestring and return the corresponding date.
Will throw a hissy fit if the date string is a duration. Will ignore any precision beyond day (hour/min/sec/usec)."
- (let ((parsed-value (parse-timestring datestring :start start :end end :junk-allowed junk-allowed)))
- (ecase (type-of parsed-value)
- (wall-time (%make-date :mjd (time-mjd parsed-value))))))
+ (etypecase datestring
+ (date datestring)
+ (wall-time (time->date datestring))
+ (string
+ (let ((parsed-value
+ (parse-timestring
+ datestring :start start :end end :junk-allowed junk-allowed)))
+ (etypecase parsed-value
+ (date parsed-value)
+ (wall-time (time->date parsed-value)))))))
(defvar *iso-8601-duration-delimiters*
(defvar *iso-8601-duration-delimiters*