(require 'rfc2231)
(require 'mm-url)
(require 'rfc2047)
+(require 'iso8601)
(require 'mml)
(require 'xml)
(not (string-match "\\`[A-Z+-]" zone)))
(setq zone nil))))
;; ISO 8601
- ((string-match
- (eval-when-compile
- (concat
- ;; 1. year
- "\\(199[0-9]\\|20[0-9][0-9]\\)"
- "\\(?:-"
- ;; 2. month
- "\\([01][0-9]\\)"
- "\\(?:-"
- ;; 3. day
- "\\([0-3][0-9]\\)"
- "\\)?\\)?\\(?:T"
- ;; 4. hh:mm
- "\\([012][0-9]:[0-5][0-9]\\)"
- "\\(?:"
- ;; 5. :ss
- "\\(:[0-5][0-9]\\)"
- "\\(?:\\.[0-9]+\\)?\\)?\\)?"
- ;; 6+7,8,9. zone
- "\\(?:\\(?:\\([+-][012][0-9]\\):\\([0-5][0-9]\\)\\)"
- "\\|\\([+-][012][0-9][0-5][0-9]\\)"
- "\\|\\(Z\\)\\)?"))
- date)
- (setq year (string-to-number (match-string 1 date))
- month (string-to-number (or (match-string 2 date) "1"))
- day (string-to-number (or (match-string 3 date) "1"))
- time (if (match-beginning 5)
- (substring date (match-beginning 4) (match-end 5))
- (concat (or (match-string 4 date) "00:00") ":00"))
- zone (cond ((match-beginning 6)
- (concat (match-string 6 date)
- (match-string 7 date)))
- ((match-beginning 9) ;; Z
- "+0000")
- (t ;; nil if zone is not provided.
- (match-string 8 date))))))
+ ((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 " " zone)
+ (concat " " (time-zone-format zone t))
"")))
(message-make-date given))))
--- /dev/null
+;;; nnrss-tests.el --- tests for gnus/nnrss.el -*- lexical-binding:t -*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'nnrss)
+
+(ert-deftest test-nnrss-normalize ()
+ (should (equal (nnrss-normalize-date "2004-09-17T05:09:49.001+00:00")
+ "Fri, 17 Sep 2004 05:09:49 +0000")))
+
+;;; nnrss-tests.el ends here