Commit 9ffbe127 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/calendar/parse-time.el (parse-time-string): Use functionp and setf

parent b793a881
...@@ -168,8 +168,7 @@ unknown DST value is returned as -1." ...@@ -168,8 +168,7 @@ unknown DST value is returned as -1."
(when (and (not (nth (car slots) time)) ;not already set (when (and (not (nth (car slots) time)) ;not already set
(setq parse-time-val (setq parse-time-val
(cond ((and (consp predicate) (cond ((and (consp predicate)
(not (eq (car predicate) (not (functionp predicate)))
'lambda)))
(and (numberp parse-time-elt) (and (numberp parse-time-elt)
(<= (car predicate) parse-time-elt) (<= (car predicate) parse-time-elt)
(or (not (cdr predicate)) (or (not (cdr predicate))
...@@ -191,7 +190,7 @@ unknown DST value is returned as -1." ...@@ -191,7 +190,7 @@ unknown DST value is returned as -1."
:end (aref this 1)) :end (aref this 1))
(funcall this))) (funcall this)))
parse-time-val))) parse-time-val)))
(rplaca (nthcdr (pop slots) time) new-val)))))))) (setf (nth (pop slots) time) new-val))))))))
time)) time))
(defconst parse-time-iso8601-regexp (defconst parse-time-iso8601-regexp
...@@ -244,16 +243,17 @@ If DATE-STRING cannot be parsed, it falls back to ...@@ -244,16 +243,17 @@ If DATE-STRING cannot be parsed, it falls back to
re-start (match-end 0)) re-start (match-end 0))
(when (string-match tz-re date-string re-start) (when (string-match tz-re date-string re-start)
(setq dst nil) (setq dst nil)
(if (string= "Z" (match-string 1 date-string)) (setq tz (if (string= "Z" (match-string 1 date-string))
(setq tz 0) ;; UTC timezone indicated by Z 0 ;; UTC timezone indicated by Z
(setq tz (+ (let ((tz (+
(* 3600 (* 3600
(string-to-number (match-string 3 date-string))) (string-to-number
(* 60 (match-string 3 date-string)))
(string-to-number (* 60
(or (match-string 4 date-string) "0"))))) (string-to-number
(when (string= "-" (match-string 2 date-string)) (or (match-string 4 date-string) "0"))))))
(setq tz (- tz))))) (if (string= "-" (match-string 2 date-string))
(- tz) tz)))))
(setq time (list seconds minute hour day month year day-of-week dst tz)))) (setq time (list seconds minute hour day month year day-of-week dst tz))))
;; Fall back to having `parse-time-string' do fancy things for us. ;; Fall back to having `parse-time-string' do fancy things for us.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment