all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christophe Deleuze <christophe.deleuze@free.fr>
To: 15408@debbugs.gnu.org
Subject: bug#15408: 23.4; icalendar import: daylight saving time
Date: Wed, 18 Sep 2013 14:54:01 +0200	[thread overview]
Message-ID: <4750.1379508841@ES0871.esisar.inpg.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 1907 bytes --]


[This is a small bug in icalendar.el.  A simple fix is provided.
Although tested on version 23.4, I checked the file icalendar.el hasn't
changed in current developpement version (downloaded for bazaar
repository on Sep 4th).]

* bug description

When importing an ics file into a diary file, date/times are not always
correctly converted from UTC to local time zone.

Example: let's import the provided mini.ics icalendar file, where
dates are in UTC (trailing 'Z'), on a system using the Europe/Paris
time zone.  This time zone has a time 2 hours ahead of UTC during
daylight saving and 1 hour ahead otherwise.

The file contains two events, the first one is planned on november 12
2013, from 12:15 to 14:00 UTC, the second one is planned on september
12 2013, from 8:00 to 9:45 UTC.

september 12 2013 is in daylight saving time period, while december 11
2013 is not.  The generated diary file (provided as mini.diary) shows
a 2 hours offset has been added to both events, while it should have
added a single hour offset to the second one.  It has been generated
on september 7 2013, during daylight saving time period.  Please note
that my emacs uses the european date display style, so that september
12 2013 is written as 12/9/2013 in the diary file.

* fix description

The function icalendar--decode-isodatetime in calendar/icalendar.el
calls (current-time-zone) to add current time zone offset when the ics
time is UTC.  However, the function is called without argument,
meaning the returned offset is the one applying at the time of
calling.

It should be called with the (UTC) date/time of the converted
date/time so that computed offset is the one in force at that precise
date/time.

The patch file icalendar.patch fixes the problem.  File
mini.diary-patched is the result of importing mini.ics with the
patched icalendar.el file.

* changelog

Small change in icalendar--decode-isodatetime.



[-- Attachment #2: example ics file --]
[-- Type: text/calendar, Size: 844 bytes --]

BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:-//ADE/version 5.2
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20130902T152652Z
DTSTART:20130912T080000Z
DTEND:20130912T094500Z
SUMMARY:TD NE210
LOCATION:A046
DESCRIPTION:\n2AMNE210_2013_S3_TD_G2\nDELEUZE Christophe\n(Exporté le:02/
 09/2013 17:26)
UID:ADE524553495341522d323031332d323031342d323130352d302d30
CREATED:19700101T000000Z
LAST-MODIFIED:20130902T152652Z
SEQUENCE:1324562812
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20130902T152652Z
DTSTART:20131211T121500Z
DTEND:20131211T140000Z
SUMMARY:TD NE210
LOCATION:B044
DESCRIPTION:\n2AMNE210_2013_S3_TD_G2\nDELEUZE Christophe\n(Exporté le:02/
 09/2013 17:26)
UID:ADE524553495341522d323031332d323031342d323130352d302d33
CREATED:19700101T000000Z
LAST-MODIFIED:20130902T152652Z
SEQUENCE:1324562812
END:VEVENT
END:VCALENDAR

[-- Attachment #3: diary from importing mini.ics (w/ bad time) --]
[-- Type: text/plain, Size: 273 bytes --]

12/9/2013 10:00-11:45 TD NE210
 Desc: 
 2AMNE210_2013_S3_TD_G2
 DELEUZE Christophe
 (Exporté le:02/09/2013 17:26)
 Location: A046
11/12/2013 14:15-16:00 TD NE210
 Desc: 
 2AMNE210_2013_S3_TD_G2
 DELEUZE Christophe
 (Exporté le:02/09/2013 17:26)
 Location: B044

[-- Attachment #4: (correct) diary from importing mini.ics w/ patch applied --]
[-- Type: text/plain, Size: 273 bytes --]

12/9/2013 10:00-11:45 TD NE210
 Desc: 
 2AMNE210_2013_S3_TD_G2
 DELEUZE Christophe
 (Exporté le:02/09/2013 17:26)
 Location: A046
11/12/2013 13:15-15:00 TD NE210
 Desc: 
 2AMNE210_2013_S3_TD_G2
 DELEUZE Christophe
 (Exporté le:02/09/2013 17:26)
 Location: B044

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: patch --]
[-- Type: text/x-diff, Size: 1333 bytes --]

*** calendar/icalendar.el.old	2013-09-04 11:17:18.000000000 +0200
--- calendar/icalendar.el	2013-09-04 11:20:29.000000000 +0200
***************
*** 562,570 ****
          (when (and (> (length isodatetimestring) 15)
                     ;; UTC specifier present
                     (char-equal ?Z (aref isodatetimestring 15)))
            ;; if not UTC add current-time-zone offset
!           (setq second (+ (car (current-time-zone)) second)))
          ;; shift if necessary
          (if day-shift
              (let ((mdy (calendar-gregorian-from-absolute
                          (+ (calendar-absolute-from-gregorian
--- 562,573 ----
          (when (and (> (length isodatetimestring) 15)
                     ;; UTC specifier present
                     (char-equal ?Z (aref isodatetimestring 15)))
            ;; if not UTC add current-time-zone offset
!           ;; 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
                          (+ (calendar-absolute-from-gregorian

             reply	other threads:[~2013-09-18 12:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 12:54 Christophe Deleuze [this message]
2014-07-30 16:33 ` bug#15408: 23.4; icalendar import: daylight saving time Ulf Jasper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4750.1379508841@ES0871.esisar.inpg.fr \
    --to=christophe.deleuze@free.fr \
    --cc=15408@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.