088b3655b45e086f809840a4ce63af2ca7934319 — Jamie Beardslee 23 days ago 6835ff2
Add additional support for Atom (ISO-8601) date strings.

* --date->time now manually parses Atom dates if the function
  iso8601-parse is unbound (new addition in Emacs 27)
* --pub-time gives additional argument to --date->time if the feed
  doesn't use RSS' pubDate tag

Co-authored-by: Alexandru-Sergiu Marton <brown121407@posteo.ro>
1 files changed, 22 insertions(+), 6 deletions(-)

M org-webring.el
M org-webring.el => org-webring.el +22 -6
@@ 221,15 221,31 @@ end. Taken from the s.el library."
      (format "%s%s" (substring s 0 (- len (length elipsis))) elipsis)

(defun org-webring--date->time (date)
  "Convert DATE string to a time value."
  (apply 'encode-time (parse-time-string date)))
(defun org-webring--date->time (date &optional atom-p)
  "Convert DATE string to a time value.
Rudimentary support for parsing ISO-8601 time strings is used
when ATOM-P is non-nil and the function `iso8601-parse' (which
was introduced in Emacs 27) isn't available."
  (apply 'encode-time
	  (cond ((fboundp #'iso8601-parse)
		  (mapconcat #'identity
			     (split-string (substring date 0 19) "T")
			     " ")
		  " +0000"))

(defun org-webring--pub-time (item)
  "Get ITEM's publication time."
   (or (org-webring--feed-text-prop item 'pubDate)
       (org-webring--feed-text-prop item 'updated))))
  (let ((atom-p (not (xml-get-children item 'pubDate))))
     (or (org-webring--feed-text-prop item 'pubDate)
	 (org-webring--feed-text-prop item 'updated))

(defun org-webring--article-instance (item)
  "Generate the structure of a feed article from a given ITEM."