Function: iso8601-parse-time
iso8601-parse-time is a byte-compiled function defined in
iso8601.el.gz.
Signature
(iso8601-parse-time STRING &optional FORM)
Documentation
Parse STRING, which should be an ISO 8601 time string.
The return value will be a decode-time structure with just the
hour/minute/seconds/zone fields filled in.
See decode-time for the meaning of FORM.
Probably introduced at or before Emacs version 27.1.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/iso8601.el.gz
(defun iso8601-parse-time (string &optional form)
"Parse STRING, which should be an ISO 8601 time string.
The return value will be a `decode-time' structure with just the
hour/minute/seconds/zone fields filled in.
See `decode-time' for the meaning of FORM."
(if (not (iso8601--match iso8601--full-time-match string))
(signal 'wrong-type-argument string)
(let ((time (match-string 1 string))
(zone (match-string 2 string)))
(if (not (iso8601--match iso8601--time-match time))
(signal 'wrong-type-argument string)
(let ((hour (string-to-number (match-string 1 time)))
(minute (and (match-string 2 time)
(string-to-number (match-string 2 time))))
(second (and (match-string 3 time)
(string-to-number (match-string 3 time))))
(frac-string (match-string 4 time))
fraction fraction-precision)
(when frac-string
;; Remove trailing zeroes.
(setq frac-string (replace-regexp-in-string "0+\\'" "" frac-string))
(when (length> frac-string 0)
(setq fraction (string-to-number frac-string)
fraction-precision (length frac-string))))
(when (and fraction
(eq form t))
(cond
;; Sub-second time.
(second
(setq second (cons (+ (* second (expt 10 fraction-precision))
fraction)
(expt 10 fraction-precision))))
;; Fractional minute.
(minute
(setq second (iso8601--decimalize fraction 60)))
(hour
;; Fractional hour.
(setq minute (iso8601--decimalize fraction 60)))))
(iso8601--decoded-time :hour hour
:minute (or minute 0)
:second (or second 0)
:zone (and zone
(* 60 (iso8601-parse-zone
zone)))))))))