From: Lars Ingebrigtsen Date: Thu, 30 Jan 2020 02:02:48 +0000 (+0100) Subject: Give fuller support for obsolete ---12 dates in iso8601 X-Git-Tag: emacs-28.0.90~7908^2~29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1ed7cd41dba444da0b66427eb48852e896ca3742;p=emacs.git Give fuller support for obsolete ---12 dates in iso8601 * lisp/calendar/iso8601.el (iso8601--outdated-reduced-precision-date-match): New constant. (iso8601--date-match): Use it. --- diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el index 858d561f188..906c29b15f4 100644 --- a/lisp/calendar/iso8601.el +++ b/lisp/calendar/iso8601.el @@ -69,6 +69,8 @@ "\\([+-]?[0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9]\\)") (defconst iso8601--outdated-date-match "--\\([0-9][0-9]\\)-?\\([0-9][0-9]\\)") +(defconst iso8601--outdated-reduced-precision-date-match + "---?\\([0-9][0-9]\\)") (defconst iso8601--week-date-match "\\([+-]?[0-9][0-9][0-9][0-9]\\)-?W\\([0-9][0-9]\\)-?\\([0-9]\\)?") (defconst iso8601--ordinal-date-match @@ -79,6 +81,7 @@ iso8601--full-date-match iso8601--without-day-match iso8601--outdated-date-match + iso8601--outdated-reduced-precision-date-match iso8601--week-date-match iso8601--ordinal-date-match))) diff --git a/test/lisp/calendar/iso8601-tests.el b/test/lisp/calendar/iso8601-tests.el index c2994ef8b4d..e8b155a7aa7 100644 --- a/test/lisp/calendar/iso8601-tests.el +++ b/test/lisp/calendar/iso8601-tests.el @@ -47,10 +47,14 @@ (ert-deftest test-iso8601-date-obsolete-2000 () ;; These are forms in 5.2.1.3 of the 2000 version of the standard, ;; e) and f). - (should (equal (iso8601-parse-date "--02") - '(nil nil nil nil 2 nil nil -1 nil))) + (should (equal (iso8601-parse-date "--12") + '(nil nil nil nil 12 nil nil -1 nil))) + (should (equal (iso8601-parse "--12T14") + '(0 0 14 nil 12 nil nil -1 nil))) (should (equal (iso8601-parse-date "---12") - '(nil nil nil 12 nil nil nil -1 nil)))) + '(nil nil nil 12 nil nil nil -1 nil))) + (should (equal (iso8601-parse "---12T14:10:12") + '(12 10 14 12 nil nil nil -1 nil)))) (ert-deftest test-iso8601-date-weeks () (should (equal (iso8601-parse-date "2008W39-6")