--- parse-time.el 2015-08-11 18:06:46.895638495 +0900 +++ parse-time_3.el 2015-08-11 20:22:45.627737133 +0900 @@ -55,6 +55,7 @@ (cond ((eq char ?+) 1) ((eq char ?-) -1) ((eq char ?:) ?d) + ((eq char ?/) ?e) ((string-match "[[:upper:]]" (setq str (string char))) ?A) ((string-match "[[:lower:]]" str) ?a) ((string-match "[[:digit:]]" str) ?0))))) @@ -156,6 +157,12 @@ (= (aref parse-time-elt 4) ?-) (= (aref parse-time-elt 7) ?-))) [0 4] [5 7] [8 10]) + ((5 4 3) + ,#'(lambda () (and (stringp parse-time-elt) + (= (length parse-time-elt) 8) + (= (aref parse-time-elt 2) ?/) + (= (aref parse-time-elt 5) ?/))) + [6 8] [0 2] [3 5]) ((2 1 0) ,#'(lambda () (and (stringp parse-time-elt) (= (length parse-time-elt) 5) @@ -182,7 +189,10 @@ The values are identical to those of `decode-time', but any values that are unknown are returned as nil." (let ((time (list nil nil nil nil nil nil nil nil nil)) - (temp (parse-time-tokenize (downcase string)))) + (temp (parse-time-tokenize (downcase string))) + (has-pm nil)) + (when (member "pm" temp) + (setq has-pm t)) (while temp (let ((parse-time-elt (pop temp)) (rules parse-time-rules) @@ -216,6 +226,13 @@ (funcall this))) parse-time-val))) (rplaca (nthcdr (pop slots) time) new-val)))))))) + (let ((year (nth 5 time))) + (cond ((and (>= year 50) (<= year 110)) + (setf (nth 5 time) (+ 1900 year))) + ((and (>= year 0) (<= year 49)) + (setf (nth 5 time) (+ 2000 year))))) + (when (and has-pm (< (nth 2 time) 12)) + (setf (nth 2 time) (+ (nth 2 time) 12))) time)) (provide 'parse-time)