emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add explicit time zone to datetime exported to ical.
@ 2010-12-22  8:24 Rémi Vanicat
  2011-02-12 20:15 ` [Accepted] " Bastien Guerry
  2011-02-12 20:16 ` [PATCH] " Bastien
  0 siblings, 2 replies; 3+ messages in thread
From: Rémi Vanicat @ 2010-12-22  8:24 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Accepted] Add explicit time zone to datetime exported to ical.
  2010-12-22  8:24 [PATCH] Add explicit time zone to datetime exported to ical Rémi Vanicat
@ 2011-02-12 20:15 ` Bastien Guerry
  2011-02-12 20:16 ` [PATCH] " Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien Guerry @ 2011-02-12 20:15 UTC (permalink / raw)
  To: emacs-orgmode

Patch 502 (http://patchwork.newartisans.com/patch/502/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C87lj3ixljr.dlv%40debian.org%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] Add explicit time zone to datetime exported to ical.
> Date: Wed, 22 Dec 2010 13:24:08 -0000
> From: =?utf-8?q?R=C3=A9mi_Vanicat_=3Cvanicat=40debian=2Eorg=3E?=
> X-Patchwork-Id: 502
> Message-Id: <87lj3ixljr.dlv@debian.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)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add explicit time zone to datetime exported to ical.
  2010-12-22  8:24 [PATCH] Add explicit time zone to datetime exported to ical Rémi Vanicat
  2011-02-12 20:15 ` [Accepted] " Bastien Guerry
@ 2011-02-12 20:16 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien @ 2011-02-12 20:16 UTC (permalink / raw)
  To: Rémi Vanicat; +Cc: emacs-orgmode

Hi Rémi,

Rémi Vanicat <vanicat@debian.org> writes:

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

Applied, Thanks.  

I also made org-icalendar-date-time-format backward compatible, it
defaults to the right value if org-icalendar-use-UTC-date-time was
set to t.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-12 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-22  8:24 [PATCH] Add explicit time zone to datetime exported to ical Rémi Vanicat
2011-02-12 20:15 ` [Accepted] " Bastien Guerry
2011-02-12 20:16 ` [PATCH] " Bastien

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).