Fix date-with-no-separator transform.

The expected string length was hard-coded, which is not a good idea given
the support for custom date formats.
This commit is contained in:
Dimitri Fontaine 2018-03-07 23:07:00 +01:00
parent 42c9ccfbb3
commit 3112adea6f

View File

@ -102,9 +102,11 @@
"Apply this function when input date in like '20041002152952'" "Apply this function when input date in like '20041002152952'"
;; only process non-zero dates ;; only process non-zero dates
(declare (type (or null string) date-string)) (declare (type (or null string) date-string))
(let ((str-length (length date-string))
(expected-length (reduce #'max (mapcar #'third format))))
(cond ((null date-string) nil) (cond ((null date-string) nil)
((string= date-string "") nil) ((string= date-string "") nil)
((not (= 14 (length date-string))) nil) ((not (= expected-length str-length)) nil)
(t (t
(destructuring-bind (&key year month day hour minute seconds (destructuring-bind (&key year month day hour minute seconds
&allow-other-keys) &allow-other-keys)
@ -116,7 +118,7 @@
(string= day "00")) (string= day "00"))
nil nil
(format nil "~a-~a-~a ~a:~a:~a" (format nil "~a-~a-~a ~a:~a:~a"
year month day hour minute seconds)))))) year month day hour minute seconds)))))))
(defun time-with-no-separator (defun time-with-no-separator
(time-string (time-string