Function: nnrss-normalize-date
nnrss-normalize-date is a byte-compiled function defined in
nnrss.el.gz.
Signature
(nnrss-normalize-date DATE)
Documentation
Return a date string of DATE in the style of RFC 822 and its successors.
This function handles the ISO 8601 date format described in URL https://www.w3.org/TR/NOTE-datetime, and also the RFC 822 style which RSS 2.0 allows.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nnrss.el.gz
(defun nnrss-normalize-date (date)
"Return a date string of DATE in the style of RFC 822 and its successors.
This function handles the ISO 8601 date format described in
URL `https://www.w3.org/TR/NOTE-datetime', and also the RFC 822 style
which RSS 2.0 allows."
(let (case-fold-search vector year month day time zone cts given)
(cond ((null date)) ; do nothing for this case
;; if the date is just digits (unix time stamp):
((string-match "^[0-9]+$" date)
(setq given (time-convert (string-to-number date))))
;; RFC 822
((string-match " [0-9]+ " date)
(setq vector (timezone-parse-date date)
year (string-to-number (aref vector 0)))
(when (>= year 1969)
(setq month (string-to-number (aref vector 1))
day (string-to-number (aref vector 2)))
(unless (>= (length (setq time (aref vector 3))) 3)
(setq time "00:00:00"))
(when (and (setq zone (aref vector 4))
(not (string-match "\\`[A-Z+-]" zone)))
(setq zone nil))))
;; ISO 8601
((iso8601-valid-p date)
(let ((decoded (decoded-time-set-defaults (iso8601-parse date))))
(setq year (decoded-time-year decoded)
month (decoded-time-month decoded)
day (decoded-time-day decoded)
time (format "%02d:%02d:%02d"
(decoded-time-hour decoded)
(decoded-time-minute decoded)
(decoded-time-second decoded))
zone (if (equal (decoded-time-zone decoded) "Z")
0
(decoded-time-zone decoded))))))
(if month
(progn
(setq cts (current-time-string (encode-time 0 0 0 day month year)))
(format "%s, %02d %s %04d %s%s"
(substring cts 0 3) day (substring cts 4 7) year time
(if zone
(concat " " (format-time-string "%z" nil zone))
"")))
(message-make-date given))))