iso8601--duration-week-match
iso8601--duration-combined-match)))
+;; "Z" dnd "z" are standard time; nil and [-+][0-9][0-9]... are local time
+;; with unknown DST.
+(defun iso8601--zone-dst (zone)
+ (if (= (length zone) 1) nil -1))
+
(defun iso8601-parse (string &optional form)
"Parse an ISO 8601 date/time string and return a `decode-time' structure.
(setf (decoded-time-zone date)
;; The time zone in decoded times are in seconds.
(* (iso8601-parse-zone zone-string) 60))
- (setf (decoded-time-dst date) nil))
+ (setf (decoded-time-dst date) (iso8601--zone-dst zone-string)))
date)))
(defun iso8601-parse-date (string)
(iso8601--decoded-time :hour hour
:minute (or minute 0)
:second (or second 0)
+ :dst (iso8601--zone-dst zone)
:zone (and zone
(* 60 (iso8601-parse-zone
zone)))))))))
(cl-defun iso8601--decoded-time (&key second minute hour
day month year
- dst zone)
+ (dst -1) zone)
(list (iso8601--value second)
(iso8601--value minute)
(iso8601--value hour)
(iso8601--value month)
(iso8601--value year)
nil
- (if (or dst zone) dst -1)
+ dst
zone))
(defun iso8601--encode-time (time)
(should (equal (iso8601-parse "2008-03-02T13:47:30Z")
'(30 47 13 2 3 2008 nil nil 0)))
(should (equal (iso8601-parse "2008-03-02T13:47:30+01:00")
- '(30 47 13 2 3 2008 nil nil 3600)))
+ '(30 47 13 2 3 2008 nil -1 3600)))
(should (equal (iso8601-parse "2008-03-02T13:47:30-01")
- '(30 47 13 2 3 2008 nil nil -3600))))
+ '(30 47 13 2 3 2008 nil -1 -3600))))
(ert-deftest test-iso8601-duration ()
(should (equal (iso8601-parse-duration "P3Y6M4DT12H30M5S")
(ert-deftest standard-test-time-of-day-zone ()
(should (equal (iso8601-parse-time "152746+0100")
- '(46 27 15 nil nil nil nil nil 3600)))
+ '(46 27 15 nil nil nil nil -1 3600)))
(should (equal (iso8601-parse-time "15:27:46+0100")
- '(46 27 15 nil nil nil nil nil 3600)))
+ '(46 27 15 nil nil nil nil -1 3600)))
(should (equal (iso8601-parse-time "152746+01")
- '(46 27 15 nil nil nil nil nil 3600)))
+ '(46 27 15 nil nil nil nil -1 3600)))
(should (equal (iso8601-parse-time "15:27:46+01")
- '(46 27 15 nil nil nil nil nil 3600)))
+ '(46 27 15 nil nil nil nil -1 3600)))
(should (equal (iso8601-parse-time "152746-0500")
- '(46 27 15 nil nil nil nil nil -18000)))
+ '(46 27 15 nil nil nil nil -1 -18000)))
(should (equal (iso8601-parse-time "15:27:46-0500")
- '(46 27 15 nil nil nil nil nil -18000)))
+ '(46 27 15 nil nil nil nil -1 -18000)))
(should (equal (iso8601-parse-time "152746-05")
- '(46 27 15 nil nil nil nil nil -18000)))
+ '(46 27 15 nil nil nil nil -1 -18000)))
(should (equal (iso8601-parse-time "15:27:46-05")
- '(46 27 15 nil nil nil nil nil -18000))))
+ '(46 27 15 nil nil nil nil -1 -18000))))
(defun test-iso8601-format-time-string-zone-round-trip (offset-minutes z-format)