Fix parsing dates with less-than 4 digits, fix #266.

The previous coding decided to add 2000 to the year as an integer if it
was below 2000, which parses 1999 as 3999. Oops. Trigger the correction
only when the date is given on 2 digits only, parsing 04 as 2004.

Dates given on 3 digits are kept as-is.

Playing with the *century* special parameter allows to cancel this
behavior, that maybe should be made entirely optional. It's just too
common to find current years on 2 digits only, sadly.
This commit is contained in:
Dimitri Fontaine 2015-07-26 14:41:44 +02:00
parent d2a1a5643e
commit b4b36caa84
3 changed files with 3 additions and 3 deletions

View File

@ -44,7 +44,8 @@
(with-output-to-string (s)
(format s "~a-~a-~a ~a:~a:~a"
(let ((yint (parse-integer year)))
(if (< yint *century*) (+ *century* yint) yint))
;; process 2-digits year formats specially
(if (<= (length year) 2) (+ *century* yint) yint))
month
day
(let ((hint (parse-integer hour)))

View File

@ -41,7 +41,6 @@
(list (cdr field-name-or-list))
(t (cdr (assoc field-name-or-list fields
:test #'string-equal))))
(declare (ignore date-format)) ; TODO
;; now prepare a function of a column
(lambda (col)
(let ((value-or-null

View File

@ -19,6 +19,6 @@ LOAD CSV
);
$$;
1,2014-10-02 00-33-12.123456
1,1999-10-02 00-33-12.123456
2,2014-10-02 00-33-13.123456
3,2014-10-02 00-33-14.123456