From: Ulf Jasper Date: Wed, 30 Jul 2014 16:25:58 +0000 (+0200) Subject: Fix Bug#15408 (icalendar time zone problem) X-Git-Tag: emacs-25.0.90~2636^3~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c99a3b8705aad133d90b634989f6f7ad1559b7b5;p=emacs.git Fix Bug#15408 (icalendar time zone problem) 2014-07-30 Christophe Deleuze * calendar/icalendar.el (icalendar--decode-isodatetime): Use actual current-time-zone when converting to local time. (Bug#15408) 2014-07-30 Ulf Jasper * automated/icalendar-tests.el (icalendar--decode-isodatetime): New test. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a89b46bf144..5bebc3af3b9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-07-30 Christophe Deleuze + + * calendar/icalendar.el (icalendar--decode-isodatetime): Use + actual current-time-zone when converting to local time. (Bug#15408) + 2014-07-29 Martin Rudalics * window.el (window--state-put-2): Handle horizontal scroll diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 4ba4869d788..9aefcac2314 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -563,7 +563,12 @@ FIXME: multiple comma-separated values should be allowed!" ;; UTC specifier present (char-equal ?Z (aref isodatetimestring 15))) ;; if not UTC add current-time-zone offset - (setq second (+ (car (current-time-zone)) second))) + ;; current-time-zone should be called with actual UTC time + ;; (daylight saving at that time may differ to current one) + (setq second (+ (car (current-time-zone + (encode-time second minute hour day month year + 0))) + second))) ;; shift if necessary (if day-shift (let ((mdy (calendar-gregorian-from-absolute diff --git a/test/ChangeLog b/test/ChangeLog index 140b5d04efd..4e47f95b066 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2014-07-30 Ulf Jasper + + * automated/icalendar-tests.el (icalendar--decode-isodatetime): New test. + 2014-07-28 Dmitry Antipov * automated/timer-tests.el (timer-tests-debug-timer-check): New test. diff --git a/test/automated/icalendar-tests.el b/test/automated/icalendar-tests.el index 7b51f907d38..2ffa3911ee3 100644 --- a/test/automated/icalendar-tests.el +++ b/test/automated/icalendar-tests.el @@ -414,6 +414,38 @@ END:VEVENT (should (not result)) )) +(ert-deftest icalendar--decode-isodatetime () + "Test `icalendar--decode-isodatetime'." + (let ((tz (getenv "TZ")) + result) + (unwind-protect + (progn + ;; Use Eastern European Time (UTC+1, UTC+2 daylight saving) + (setenv "TZ" "EET") + + (message "%s" (current-time-zone (encode-time 0 0 10 1 1 2013 0))) + (message "%s" (current-time-zone (encode-time 0 0 10 1 8 2013 0))) + + ;; testcase: no time zone in input -> keep time as is + ;; 1 Jan 2013 10:00 + (should (equal '(0 0 10 1 1 2013 2 nil 7200) + (icalendar--decode-isodatetime "20130101T100000"))) + ;; 1 Aug 2013 10:00 (DST) + (should (equal '(0 0 10 1 8 2013 4 t 10800) + (icalendar--decode-isodatetime "20130801T100000"))) + + ;; testcase: UTC time zone specifier in input -> convert to local time + ;; 31 Dec 2013 23:00 UTC -> 1 Jan 2013 01:00 EET + (should (equal '(0 0 1 1 1 2014 3 nil 7200) + (icalendar--decode-isodatetime "20131231T230000Z"))) + ;; 1 Aug 2013 10:00 UTC -> 1 Aug 2013 13:00 EEST + (should (equal '(0 0 13 1 8 2013 4 t 10800) + (icalendar--decode-isodatetime "20130801T100000Z"))) + + ) + ;; restore time-zone even if something went terribly wrong + (setenv "TZ" tz))) ) + ;; ====================================================================== ;; Export tests ;; ======================================================================