Function: erc--decode-time-period

erc--decode-time-period is a byte-compiled function defined in erc.el.gz.

Signature

(erc--decode-time-period PERIOD)

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc--decode-time-period (period)
  (progn ; unprogn on next major refactor
    (cond
     ;; Blank input.
     ((zerop (length period))
      nil)
     ;; All-number -- interpret as seconds.
     ((string-match-p "\\`[0-9]+\\'" period)
      (string-to-number period))
     ;; Parse as a time spec.
     (t
      (require 'time-date)
      (require 'iso8601)
      (let ((time (condition-case nil
                      (iso8601-parse-duration
                       (concat (cond
                                ((string-match-p "\\`P" (upcase period))
                                 ;; Somebody typed in a full ISO8601 period.
                                 (upcase period))
                                ((string-match-p "[YD]" (upcase period))
                                 ;; If we have a year/day element,
                                 ;; we have a full spec.
                                 "P")
                                (t
                                 ;; Otherwise it's just a sub-day spec.
                                 "PT"))
                               (upcase period)))
                    (wrong-type-argument nil))))
        (unless time
          (user-error "%s is not a valid time period" period))
        (decoded-time-period time))))))