[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: nnrss should borrow nnshibmun's RSS date processor...or something



Katsumi Yamaoka <yamaoka@xxxxxxx> writes:

>>>>>> In [emacs-w3m : No.08473] Mark Plaksin wrote:
>
>> Some RSS feeds provide the date in ISO 8601 date format.  sb-rss.el from
>> nnshimbun converts from ISO 8601 to a format that Gnus can handle.  nnrss
>> does no conversion so Gnus ends up saying the date is the start of the Unix
>> epoch.
>
> Gnus will be able to handle ISO 8601 date if we replace every
> `parse-time-string' that Gnus uses with `date-to-time' which
> uses timezone.el.  However, it is effective only in Emacs 22,
> because timezone.el distributed with Emacs 21 doesn't understand
> ISO 8601 date.  For instance:
>
> (timezone-parse-date "2005-12-22T13:14:03+09:00")
> ;; Emacs 22.0.50
>  => ["2005" "12" "22" "13:14:03" nil]
> ;; Emacs 21.4
>  => ["0" "0" "0" "0" nil]

The relevant timezone.el differences between 21.4 and 22.0.50 are very
small--just three regexps in timezone-parse-date.  Perhaps Gnus should
switch to date-to-time, include the newer timezone-parse-date and invoke
it when running in Emacs < 22.

Here's one way to include the newer timezone-parse-date but it looks ugly
and the Elisp docs say "In general, well-designed Lisp programs should not
use this feature [eval-after-load]."

(if (< emacs-major-version 22)
    (eval-after-load "timezone" 
      '(defun timezone-parse-date (date)
         ... ;; include definition from Emacs 22
         )))

Is there a better way or a better plan?

>> It would be nice if the conversion function from sb-rss.el were put into
>> some library that nnrss could easily call.  It's not clear to me where the
>> best place for that would be.
>
> I think it should be done in nnrss.el since parse-time.el and
> time-date.el belong to Emacs, not Gnus.

If Gnus switches to date-to-time, then no change will be needed in nnrss,
yes?

>> For the moment, I hacked my copy of nnrss.el to call an un-shimbuned
>> version of shimbun-rss-process-date.
>
> It seems to have to be used before using `message-make-date' in
> the `nnrss-check-group' function.  Could you present it?

I copied shimbun-rss-process-date, changed the first line from this:

(luna-define-method shimbun-rss-process-date ((shimbun shimbun-rss) date)

to this:

(defun map-shimbun-rss-date (date)

and then patched nnrss.el with the attached patch.

> BTW, why do you prefer RFC822 date rather than ISO 8601 date?
> If it is for the bugfix, we should apply it to both the Gnus
> trunk and the v5-10 branch.

I don't know enough to prefer either format :)  I was just trying to find a
way to make nnrss show the correct date all the time.  Making nnrss able to
do this in both the trunk and v5-10 sounds good to me though I only use
trunk.
--- nnrss.el.orig	2005-12-21 12:43:03.000000000 -0500
+++ nnrss.el	2005-12-21 22:44:04.000000000 -0500
@@ -599,9 +601,10 @@
 	(setq author (or (nnrss-node-text rss-ns 'author item)
 			 (nnrss-node-text dc-ns 'creator item)
 			 (nnrss-node-text dc-ns 'contributor item)))
-	(setq date (or (nnrss-node-text dc-ns 'date item)
-		       (nnrss-node-text rss-ns 'pubDate item)
-		       (message-make-date)))
+	(setq date (map-shimbun-rss-date
+                    (or (nnrss-node-text dc-ns 'date item)
+                        (nnrss-node-text rss-ns 'pubDate item)
+                        (message-make-date))))
 	(setq comments (nnrss-node-text rss-ns 'comments item))
 	(when (setq enclosure (cadr (assq (intern (concat rss-ns "enclosure")) item)))
 	  (let ((url (cdr (assq 'url enclosure)))