+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
;; 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
+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.
(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
;; ======================================================================