diff options
| author | Lars Ingebrigtsen | 2020-01-30 02:11:09 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-01-30 02:11:15 +0100 |
| commit | 7c7b91b9fe156b6af4643ca4aa8f4a5c4aeb915f (patch) | |
| tree | 5b939400040405df08d6946620793b1a3a2237e9 | |
| parent | 5db3324a7e11280437e69e27fe364dfd80b66ca2 (diff) | |
| download | emacs-7c7b91b9fe156b6af4643ca4aa8f4a5c4aeb915f.tar.gz emacs-7c7b91b9fe156b6af4643ca4aa8f4a5c4aeb915f.zip | |
Make iso8601.el understand two obsolete forms
* lisp/calendar/iso8601.el (iso8601-parse-date): Understand some
obsolete formats to provide compatibility with the vCard RFC
(bug#39347).
| -rw-r--r-- | lisp/calendar/iso8601.el | 6 | ||||
| -rw-r--r-- | test/lisp/calendar/iso8601-tests.el | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el index e42fe0fa21f..858d561f188 100644 --- a/lisp/calendar/iso8601.el +++ b/lisp/calendar/iso8601.el | |||
| @@ -202,6 +202,12 @@ See `decode-time' for the meaning of FORM." | |||
| 202 | (iso8601--decoded-time :year year | 202 | (iso8601--decoded-time :year year |
| 203 | :month (decoded-time-month month-day) | 203 | :month (decoded-time-month month-day) |
| 204 | :day (decoded-time-day month-day)))) | 204 | :day (decoded-time-day month-day)))) |
| 205 | ;; Obsolete format with implied year: --MM | ||
| 206 | ((iso8601--match "--\\([0-9][0-9]\\)" string) | ||
| 207 | (iso8601--decoded-time :month (string-to-number (match-string 1 string)))) | ||
| 208 | ;; Obsolete format with implied year and month: ---DD | ||
| 209 | ((iso8601--match "---\\([0-9][0-9]\\)" string) | ||
| 210 | (iso8601--decoded-time :day (string-to-number (match-string 1 string)))) | ||
| 205 | (t | 211 | (t |
| 206 | (signal 'wrong-type-argument string)))) | 212 | (signal 'wrong-type-argument string)))) |
| 207 | 213 | ||
diff --git a/test/lisp/calendar/iso8601-tests.el b/test/lisp/calendar/iso8601-tests.el index 6e7a4724a6b..c2994ef8b4d 100644 --- a/test/lisp/calendar/iso8601-tests.el +++ b/test/lisp/calendar/iso8601-tests.el | |||
| @@ -44,6 +44,14 @@ | |||
| 44 | (should (equal (iso8601-parse-date "--0201") | 44 | (should (equal (iso8601-parse-date "--0201") |
| 45 | '(nil nil nil 1 2 nil nil -1 nil)))) | 45 | '(nil nil nil 1 2 nil nil -1 nil)))) |
| 46 | 46 | ||
| 47 | (ert-deftest test-iso8601-date-obsolete-2000 () | ||
| 48 | ;; These are forms in 5.2.1.3 of the 2000 version of the standard, | ||
| 49 | ;; e) and f). | ||
| 50 | (should (equal (iso8601-parse-date "--02") | ||
| 51 | '(nil nil nil nil 2 nil nil -1 nil))) | ||
| 52 | (should (equal (iso8601-parse-date "---12") | ||
| 53 | '(nil nil nil 12 nil nil nil -1 nil)))) | ||
| 54 | |||
| 47 | (ert-deftest test-iso8601-date-weeks () | 55 | (ert-deftest test-iso8601-date-weeks () |
| 48 | (should (equal (iso8601-parse-date "2008W39-6") | 56 | (should (equal (iso8601-parse-date "2008W39-6") |
| 49 | '(nil nil nil 27 9 2008 nil -1 nil))) | 57 | '(nil nil nil 27 9 2008 nil -1 nil))) |