1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-03 11:33:37 +00:00

Fix Bug#15408 (icalendar time zone problem)

2014-07-30 Christophe Deleuze <christophe.deleuze@free.fr>

	* calendar/icalendar.el (icalendar--decode-isodatetime): Use
	actual current-time-zone when converting to local time. (Bug#15408)

2014-07-30  Ulf Jasper  <ulf.jasper@web.de>

	* automated/icalendar-tests.el (icalendar--decode-isodatetime): New test.
This commit is contained in:
Ulf Jasper 2014-07-30 18:25:58 +02:00
parent 609fc791b8
commit c99a3b8705
4 changed files with 47 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2014-07-30 Christophe Deleuze <christophe.deleuze@free.fr>
* calendar/icalendar.el (icalendar--decode-isodatetime): Use
actual current-time-zone when converting to local time. (Bug#15408)
2014-07-29 Martin Rudalics <rudalics@gmx.at>
* window.el (window--state-put-2): Handle horizontal scroll

View File

@ -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

View File

@ -1,3 +1,7 @@
2014-07-30 Ulf Jasper <ulf.jasper@web.de>
* automated/icalendar-tests.el (icalendar--decode-isodatetime): New test.
2014-07-28 Dmitry Antipov <dmantipov@yandex.ru>
* automated/timer-tests.el (timer-tests-debug-timer-check): New test.

View File

@ -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
;; ======================================================================