Function: math-parse-iso-date

math-parse-iso-date is a byte-compiled function defined in calc-forms.el.gz.

Signature

(math-parse-iso-date PD-STR)

Documentation

Parse PD-STR as an ISO week date, or return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-forms.el.gz
(defun math-parse-iso-date (pd-str)
  "Parse PD-STR as an ISO week date, or return nil."
  (let ((math-pd-str pd-str)
        (case-fold-search t)
        (isoyear nil) (isoweek nil) (isoweekday nil)
        (hour nil) (minute nil) (second nil))
    ;; Extract the time, if any.
    (if (string-match "T[^0-9]*\\([0-9][0-9]\\)[^0-9]*\\([0-9][0-9]\\)?[^0-9]*\\([0-9][0-9]\\(\\.[0-9]+\\)?\\)?" math-pd-str)
        (progn
          (setq hour (string-to-number (math-match-substring math-pd-str 1))
                minute (math-match-substring math-pd-str 2)
                second (math-match-substring math-pd-str 3)
                math-pd-str (substring math-pd-str 0 (match-beginning 0)))
          (if (equal minute "")
              (setq minute 0)
            (setq minute (string-to-number minute)))
          (if (equal second "")
              (setq second 0)
            (setq second (math-read-number second)))))
    ;; Next, the year, week and weekday
    (if (string-match "\\(-?[0-9]*\\)[^0-9]*W\\([0-9][0-9]\\)[^0-9]*\\([0-9]\\)[^0-9]*\\'" math-pd-str)
        (progn
          (setq isoyear (string-to-number (math-match-substring math-pd-str 1))
                isoweek (string-to-number (math-match-substring math-pd-str 2))
                isoweekday (string-to-number (math-match-substring math-pd-str 3)))
          (math-parse-iso-date-validate isoyear isoweek isoweekday hour minute second)))))