From: Ulf Jasper Date: Sun, 16 Nov 2014 16:23:45 +0000 (+0100) Subject: icalendar: fix issues regarding timezones without dst X-Git-Tag: emacs-25.0.90~2635^2~450 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7261b4d9b2f35c3e520b488a8ba3cfde30f84a24;p=emacs.git icalendar: fix issues regarding timezones without dst * lisp/calendar/icalendar.el (icalendar--convert-tz-offset): Return complete cons when offsets of standard time and daylight saving time are equal. (icalendar-export-region): Fix unbound variable warning. * test/automated/icalendar-tests.el (icalendar--parse-vtimezone): Add testcase where offsets of standard time and daylight saving time are equal. (icalendar-real-world): Fix error in test case. Expected result was wrong when offsets of standard time and daylight saving time were equal. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bdf73e827d1..9d22d7609e2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2014-11-16 Ulf Jasper + + * calendar/icalendar.el (icalendar--convert-tz-offset): Return + complete cons when offsets of standard time and daylight saving + time are equal. + (icalendar-export-region): Fix unbound variable warning. + 2014-11-16 Fabián Ezequiel Gallina * progmodes/python.el (run-python): Allow CMD to be optional and diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index b024a38f809..9dba6ff2dcf 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -509,15 +509,19 @@ The strings are suitable for assembling into a TZ variable." ":" (substring offsetto 3 5)) ;; The start time. - (unless no-dst - (let* ((day (icalendar--get-weekday-number (substring byday -2))) - (week (if (eq day -1) + (let* ((day (if no-dst + 1 + (icalendar--get-weekday-number (substring byday -2)))) + (week (if no-dst + "1" + (if (eq day -1) byday - (substring byday 0 -2)))) + (substring byday 0 -2))))) ;; "Translate" the iCalendar way to specify the last ;; (sun|mon|...)day in month to the tzset way. (if (string= week "-1") ; last day as iCalendar calls it (setq week "5")) ; last day as tzset calls it + (when no-dst (setq bymonth "1")) (concat "M" bymonth "." week "." (if (eq day -1) "0" (int-to-string day)) ;; Start time. @@ -526,7 +530,7 @@ The strings are suitable for assembling into a TZ variable." ":" (substring dtstart -4 -2) ":" - (substring dtstart -2)))))))))) + (substring dtstart -2))))))))) (defun icalendar--parse-vtimezone (alist) "Turn a VTIMEZONE ALIST into a cons (ID . TZ-STRING). @@ -1025,7 +1029,8 @@ FExport diary data into iCalendar file: ") (found-error nil) (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol) "?")) - (other-elements nil)) + (other-elements nil) + (cns-cons-or-list nil)) ;; prepare buffer with error messages (save-current-buffer (set-buffer (get-buffer-create "*icalendar-errors*")) diff --git a/test/ChangeLog b/test/ChangeLog index e0e04bc262c..4a6f0059344 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,12 @@ +2014-11-16 Ulf Jasper + + * automated/icalendar-tests.el (icalendar--parse-vtimezone): Add + testcase where offsets of standard time and daylight saving time + are equal. + (icalendar-real-world): Fix error in test case. Expected result + was wrong when offsets of standard time and daylight saving time + were equal. + 2014-11-16 Fabián Ezequiel Gallina * automated/python-tests.el diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index a6a5da2ff57..23afb14792d 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -232,6 +232,27 @@ END:VTIMEZONE (should (string= "anothername, with a comma" (car result))) (message (cdr result)) (should (string= "STD-02:00DST-03:00,M3.2.1/03:00:00,M10.2.1/04:00:00" + (cdr result))) + ;; offsetfrom = offsetto + (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE +TZID:Kolkata\, Chennai\, Mumbai\, New Delhi +X-MICROSOFT-CDO-TZID:23 +BEGIN:STANDARD +DTSTART:16010101T000000 +TZOFFSETFROM:+0530 +TZOFFSETTO:+0530 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T000000 +TZOFFSETFROM:+0530 +TZOFFSETTO:+0530 +END:DAYLIGHT +END:VTIMEZONE +")) + (setq result (icalendar--parse-vtimezone vtimezone)) + (should (string= "Kolkata, Chennai, Mumbai, New Delhi" (car result))) + (message (cdr result)) + (should (string= "STD-05:30DST-05:30,M1.1.1/00:00:00,M1.1.1/00:00:00" (cdr result))))) (ert-deftest icalendar--convert-ordinary-to-ical () @@ -1389,14 +1410,14 @@ END:VALARM END:VEVENT END:VCALENDAR" nil - "&9/5/2003 10:30-15:30 On-Site Interview + "&9/5/2003 07:00-12:00 On-Site Interview Desc: 10:30am - Blah Location: Cccc Organizer: MAILTO:aaaaaaa@aaaaaaa.com Status: CONFIRMED UID: 040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000010000000DB823520692542408ED02D7023F9DFF9 " - "&5/9/2003 10:30-15:30 On-Site Interview + "&5/9/2003 07:00-12:00 On-Site Interview Desc: 10:30am - Blah Location: Cccc Organizer: MAILTO:aaaaaaa@aaaaaaa.com