From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?R=C3=A9mi_Vanicat?= Subject: [PATCH] Add explicit time zone to datetime exported to ical. Date: Wed, 22 Dec 2010 09:24:08 +0100 Message-ID: <87lj3ixljr.dlv@debian.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=48439 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PVK0F-0004Ay-Oj for emacs-orgmode@gnu.org; Wed, 22 Dec 2010 03:25:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PVJzj-0004wA-AC for emacs-orgmode@gnu.org; Wed, 22 Dec 2010 03:24:55 -0500 Received: from lo.gmane.org ([80.91.229.12]:43058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PVJzi-0004w0-T6 for emacs-orgmode@gnu.org; Wed, 22 Dec 2010 03:24:23 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PVJzh-00010Q-DR for emacs-orgmode@gnu.org; Wed, 22 Dec 2010 09:24:21 +0100 Received: from 78.116.51.24 ([78.116.51.24]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Dec 2010 09:24:21 +0100 Received: from vanicat by 78.116.51.24 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 22 Dec 2010 09:24:21 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org When exporting to ical, using localtime is incompatible with some software, using explicit universal time may failed with daylight saving time, so we need another possibility, that is localtime with explicit timezone. --- lisp/org-icalendar.el | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lisp/org-icalendar.el b/lisp/org-icalendar.el index d4034fe..1dfd3ed 100644 --- a/lisp/org-icalendar.el +++ b/lisp/org-icalendar.el @@ -194,12 +194,25 @@ When nil of the empty string, use the abbreviation retrieved from Emacs." (const :tag "Unspecified" nil) (string :tag "Time zone"))) -(defcustom org-icalendar-use-UTC-date-time () - "Non-nil force the use of the universal time for iCalendar DATE-TIME. -The iCalendar DATE-TIME can be expressed with local time or universal Time, -universal time could be more compatible with some external tools." +(defcustom org-icalendar-date-time-format ":%Y%m%dT%H%M%S" + "format-string for exporting icalendar DATE-TIME. +See `format-time-string' for a full documentation. The only +difference is that `org-icalendar-timezone' is used for %Z + +Interesting value are: + - \":%Y%m%dT%H%M%S\" for local time + - \";TZID=%Z:%Y%m%dT%H%M%S\" for local time with explicit timezone + - \":%Y%m%dT%H%M%SZ\" for time expressed in Universal Time" + :group 'org-export-icalendar - :type 'boolean) + :type '(choice + (const :tag "Local time" ":%Y%m%dT%H%M%S") + (const :tag "Explicit local time" ";TZID=%Z:%Y%m%dT%H%M%S") + (const :tag "Universal time" ":%Y%m%dT%H%M%SZ") + (string :tag "Explicit format"))) + +(defun org-icalendar-use-UTC-date-timep () + (char-equal (elt org-icalendar-date-time-format (1- (length org-icalendar-date-time-format))) ?Z)) ;;; iCalendar export @@ -641,12 +654,11 @@ a time), or the day by one (if it does not contain a time)." (setq h (+ 2 h))) (setq d (1+ d)))) (setq time (encode-time s mi h d m y))) - (setq fmt (if have-time (if org-icalendar-use-UTC-date-time - ":%Y%m%dT%H%M%SZ" - ":%Y%m%dT%H%M%S") + (setq fmt (if have-time + (replace-regexp-in-string "%Z" org-icalendar-timezone org-icalendar-date-time-format) ";VALUE=DATE:%Y%m%d")) (concat keyword (format-time-string fmt time - (and org-icalendar-use-UTC-date-time + (and (org-icalendar-use-UTC-date-timep) have-time)))))) (provide 'org-icalendar) -- 1.7.2.3