emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117612: Fix Bug#15408 (icalendar time zone problem)


From: Ulf Jasper
Subject: [Emacs-diffs] trunk r117612: Fix Bug#15408 (icalendar time zone problem)
Date: Wed, 30 Jul 2014 16:26:05 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117612
revision-id: address@hidden
parent: address@hidden
committer: Ulf Jasper <address@hidden>
branch nick: trunk
timestamp: Wed 2014-07-30 18:25:58 +0200
message:
  Fix Bug#15408 (icalendar time zone problem)
  
  2014-07-30 Christophe Deleuze <address@hidden>
  
        * calendar/icalendar.el (icalendar--decode-isodatetime): Use
        actual current-time-zone when converting to local time. (Bug#15408)
  
  2014-07-30  Ulf Jasper  <address@hidden>
  
        * automated/icalendar-tests.el (icalendar--decode-isodatetime): New 
test.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/calendar/icalendar.el     
icalendar.el-20091113204419-o5vbwnq5f7feedwu-3296
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/icalendar-tests.el 
icalendartestsuite.e-20091113204419-o5vbwnq5f7feedwu-8590
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-07-29 15:08:30 +0000
+++ b/lisp/ChangeLog    2014-07-30 16:25:58 +0000
@@ -1,3 +1,8 @@
+2014-07-30 Christophe Deleuze <address@hidden>
+
+       * calendar/icalendar.el (icalendar--decode-isodatetime): Use
+       actual current-time-zone when converting to local time. (Bug#15408)
+
 2014-07-29  Martin Rudalics  <address@hidden>
 
        * window.el (window--state-put-2): Handle horizontal scroll

=== modified file 'lisp/calendar/icalendar.el'
--- a/lisp/calendar/icalendar.el        2014-01-01 07:43:34 +0000
+++ b/lisp/calendar/icalendar.el        2014-07-30 16:25:58 +0000
@@ -563,7 +563,12 @@
                    ;; 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

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2014-07-28 06:28:15 +0000
+++ b/test/ChangeLog    2014-07-30 16:25:58 +0000
@@ -1,3 +1,7 @@
+2014-07-30  Ulf Jasper  <address@hidden>
+
+       * automated/icalendar-tests.el (icalendar--decode-isodatetime): New 
test.
+
 2014-07-28  Dmitry Antipov  <address@hidden>
 
        * automated/timer-tests.el (timer-tests-debug-timer-check): New test.

=== modified file 'test/automated/icalendar-tests.el'
--- a/test/automated/icalendar-tests.el 2014-07-26 12:53:36 +0000
+++ b/test/automated/icalendar-tests.el 2014-07-30 16:25:58 +0000
@@ -414,6 +414,38 @@
     (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
 ;; ======================================================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]