Accept even more ragged date format input.

When parsing a date string from a date format, accept that the ms or us part
be completely missing, rather than just missing some digits.

Fixed #828.
This commit is contained in:
Dimitri Fontaine 2018-09-10 19:33:39 +02:00
parent 5119d864f4
commit d356bd501b
3 changed files with 6 additions and 3 deletions

View File

@ -38,11 +38,12 @@
:for ragged-end := (when end
(cond ((member name '(:msecs :usecs))
;; take any number of digits up to
;; the specified field lenght
;; the specified field length
;; (less digits are allowed)
(min end (length date-string)))
(when (<= start (length date-string))
(min end (length date-string))))
(t end)))
:when (and start end)
:when (and start ragged-end)
:append (list name (subseq date-string start ragged-end)))
(if (or (string= year "0000")
(string= month "00")

View File

@ -28,3 +28,4 @@ LOAD CSV
1,10-02-1999 00-33-12.123456,"00:05.02"
2,10-02-2014 00-33-13.123,"18:25.52"
3,10-02-2014 00-33-14.1234,13:14.15
4,10-09-2018 19-24-59,19:24.59

View File

@ -1,3 +1,4 @@
1 1999-10-02 00:33:12.123456+02 00:05:02
2 2014-10-02 00:33:13.123+02 18:25:52
3 2014-10-02 00:33:14.1234+02 13:14:15
4 2018-10-09 19:24:59+02 19:24:59