From: Eli Zaretskii Date: Sat, 13 Apr 2024 07:52:55 +0000 (+0300) Subject: Fix Icalendar export with ISO dates X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8e4a43dc51396e0a13a9332229b6f5c4dcdc8004;p=emacs.git Fix Icalendar export with ISO dates * lisp/calendar/icalendar.el (icalendar--datestring-to-isodate): Accept dashes in ISO-style numeric dates. Patch by Erwan Hingant . (Bug#69894) * test/lisp/calendar/icalendar-tests.el (icalendar--datestring-to-isodate): Add a test for dashes in ISO-style numeric dates. (cherry picked from commit 71f8b2c3242b9b9455e9c6f25ad99ea900a1422f) --- diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index b8d5862f8c2..e536a0bcf85 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -895,8 +895,8 @@ it uses the current calendar date style." (save-match-data (cond ( ;; iso-style numeric date (string-match (concat "\\s-*" - "\\([0-9]\\{4\\}\\)[ \t/]\\s-*" - "0?\\([1-9][0-9]?\\)[ \t/]\\s-*" + "\\([0-9]\\{4\\}\\)[ \t/-]\\s-*" + "0?\\([1-9][0-9]?\\)[ \t/-]\\s-*" "0?\\([1-9][0-9]?\\)") datestring) (setq year (read (substring datestring (match-beginning 1) diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el index 39ad735a789..32c06cbc533 100644 --- a/test/lisp/calendar/icalendar-tests.el +++ b/test/lisp/calendar/icalendar-tests.el @@ -368,6 +368,9 @@ END:VTIMEZONE (icalendar--datestring-to-isodate "2008 05 31"))) (should (string= "20080602" (icalendar--datestring-to-isodate "2008 05 31" 2))) + ;; Bug#69894 + (should (string= "20240319" + (icalendar--datestring-to-isodate "2024-03-19"))) ;; numeric european (setq calendar-date-style 'european)