From 74e9799bd89484b8d15bdd6597c68fc00d07e7f7 Mon Sep 17 00:00:00 2001 From: Ulf Jasper Date: Mon, 9 Sep 2019 18:35:02 +0200 Subject: [PATCH] Handle missing start-time when importing ical event (Bug#33277) * lisp/calendar/icalendar.el (icalendar--convert-ical-to-diary): Set start time only if it is explicitly given in ical. Do not use start-time as default for end-time (Bug#33277). * test/lisp/calendar/icalendar-tests.el (icalendar-import-bug-33277): New. Test fix for Bug#33277. --- lisp/calendar/icalendar.el | 7 ++++--- test/lisp/calendar/icalendar-tests.el | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 3c46982c7b0..3ae0fcbe977 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -2095,7 +2095,9 @@ written into the buffer `*icalendar-errors*'." dtstart-zone)) (start-d (icalendar--datetime-to-diary-date dtstart-dec)) - (start-t (icalendar--datetime-to-colontime dtstart-dec)) + (start-t (and dtstart + (> (length dtstart) 8) + (icalendar--datetime-to-colontime dtstart-dec))) (dtend (icalendar--get-event-property e 'DTEND)) (dtend-zone (icalendar--find-time-zone (icalendar--get-event-property-attributes @@ -2148,8 +2150,7 @@ written into the buffer `*icalendar-errors*'." (icalendar--get-event-property-attributes e 'DTEND)) "DATE"))) - (icalendar--datetime-to-colontime dtend-dec) - start-t)) + (icalendar--datetime-to-colontime dtend-dec))) (icalendar--dmsg "start-d: %s, end-d: %s" start-d end-d) (cond ;; recurring event diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el index baea4804045..0d7004d7106 100644 --- a/test/lisp/calendar/icalendar-tests.el +++ b/test/lisp/calendar/icalendar-tests.el @@ -1300,6 +1300,24 @@ UID:9188710a-08a7-4061-bae3-d4cf4972599a " )) +(ert-deftest icalendar-import-bug-33277 () + ;;bug#33277 -- start time equals end time + (icalendar-tests--test-import + "DTSTART:20181105T200000Z +DTSTAMP:20181105T181652Z +DESCRIPTION: +LAST-MODIFIED:20181105T181646Z +LOCATION: +SEQUENCE:0 +SUMMARY:event with same start/end time +TRANSP:OPAQUE +" + + "&2018/11/5 21:00 event with same start/end time\n" + "&5/11/2018 21:00 event with same start/end time\n" + "&11/5/2018 21:00 event with same start/end time\n" + )) + (ert-deftest icalendar-import-multiple-vcalendars () (icalendar-tests--test-import "DTSTART;VALUE=DATE:20110723 -- 2.39.5