[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 8c04e65 01/12: Have newsticker use iso8601 to parse
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 8c04e65 01/12: Have newsticker use iso8601 to parse dates |
Date: |
Wed, 31 Jul 2019 15:47:57 -0400 (EDT) |
branch: master
commit 8c04e65622cbff1417727162d9b0c455cb87ed73
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Have newsticker use iso8601 to parse dates
* lisp/net/newst-backend.el (newsticker--decode-iso8601-date): Use
iso8601 to parse.
---
lisp/net/newst-backend.el | 65 ++++++++---------------------------------------
1 file changed, 10 insertions(+), 55 deletions(-)
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el
index e356a0e..5064610 100644
--- a/lisp/net/newst-backend.el
+++ b/lisp/net/newst-backend.el
@@ -37,6 +37,7 @@
(require 'derived)
(require 'xml)
(require 'url-parse)
+(require 'iso8601)
;; Silence warnings
(defvar w3-mode-map)
@@ -1594,61 +1595,15 @@ This function calls `message' with arguments STRING and
ARGS, if
;;(not (current-message))
(apply 'message string args)))
-(defun newsticker--decode-iso8601-date (iso8601-string)
- "Return ISO8601-STRING in format like `decode-time'.
-Converts from ISO-8601 to Emacs representation.
-Examples:
-2004-09-17T05:09:49.001+00:00
-2004-09-17T05:09:49+00:00
-2004-09-17T05:09+00:00
-2004-09-17T05:09:49
-2004-09-17T05:09
-2004-09-17
-2004-09
-2004"
- (if iso8601-string
- (when (string-match
- (concat
- "^ *\\([0-9]\\{4\\}\\)" ;year
- "\\(-\\([0-9]\\{2\\}\\)" ;month
- "\\(-\\([0-9]\\{2\\}\\)" ;day
- "\\(T"
- "\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" ;hour:minute
- "\\(:\\([0-9]\\{2\\}\\)\\(\\.[0-9]+\\)?\\)?" ;second
- ;timezone
- "\\(\\([-+Z]\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)?"
- "\\)?\\)?\\)? *$")
- iso8601-string)
- (let ((year (read (match-string 1 iso8601-string)))
- (month (read (or (match-string 3 iso8601-string)
- "1")))
- (day (read (or (match-string 5 iso8601-string)
- "1")))
- (hour (read (or (match-string 7 iso8601-string)
- "0")))
- (minute (read (or (match-string 8 iso8601-string)
- "0")))
- (second (read (or (match-string 10 iso8601-string)
- "0")))
- (sign (match-string 13 iso8601-string))
- (offset-hour (read (or (match-string 15 iso8601-string)
- "0")))
- (offset-minute (read (or (match-string 16 iso8601-string)
- "0"))))
- (cond ((string= sign "+")
- (setq hour (- hour offset-hour))
- (setq minute (- minute offset-minute)))
- ((string= sign "-")
- (setq hour (+ hour offset-hour))
- (setq minute (+ minute offset-minute))))
- ;; if UTC subtract current-time-zone offset
- ;;(setq second (+ (car (current-time-zone)) second)))
-
- (condition-case nil
- (encode-time second minute hour day month year t)
- (error
- (message "Cannot decode \"%s\"" iso8601-string)
- nil))))
+(defun newsticker--decode-iso8601-date (string)
+ "Return ISO8601-STRING in format like `encode-time'.
+Converts from ISO-8601 to Emacs representation."
+ (if string
+ (condition-case nil
+ (encode-time (iso8601-parse string))
+ (wrong-type-argument
+ (message "Cannot decode \"%s\"" string)
+ nil))
nil))
(defun newsticker--decode-rfc822-date (rfc822-string)
- [Emacs-diffs] master updated (794f8f2 -> a79e96f), Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master 8c04e65 01/12: Have newsticker use iso8601 to parse dates,
Lars Ingebrigtsen <=
- [Emacs-diffs] master 07ce3be 02/12: `decoded-time-set-defaults' refactored out from iso8601 code, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master 46df7bb 03/12: Add new function time-zone-format, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master 14c0a63 04/12: Make time-zone-format take a SHORT parameter, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master e82ae1d 06/12: decoded-time-dst doc fix, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master 6a87416 05/12: Use iso8601-parse in nnrss, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master 4dcb692 07/12: Default DST to "undecided" in decoded-time-set-defaults, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master fa648a5 08/12: Allow timezone defaults in decoded-time-set-defaults, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master 1ab6445 10/12: Fix time zone in previous rewrite of newsticker--decode-iso8601-date, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master c8f1e17 11/12: Rewrite `url-dav-process-date-property' to use parse-time, Lars Ingebrigtsen, 2019/07/31
- [Emacs-diffs] master a79e96f 12/12: Add more icalendar tests (for the isodatetime parser), Lars Ingebrigtsen, 2019/07/31