From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Toke_H=C3=B8iland-J=C3=B8rgensen?= Subject: Adding support for limits and exclusions to iCal recurring events Date: Sun, 07 Jul 2013 17:55:44 +0200 Message-ID: <87ehbaxt33.fsf@toke.dk> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvrJc-0003bX-KS for emacs-orgmode@gnu.org; Sun, 07 Jul 2013 11:55:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UvrJX-00052K-S5 for emacs-orgmode@gnu.org; Sun, 07 Jul 2013 11:55:56 -0400 Received: from mail.tohojo.dk ([188.40.53.186]:36879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvrJX-0004zV-AY for emacs-orgmode@gnu.org; Sun, 07 Jul 2013 11:55:51 -0400 Received: from alrua-desktop.borgediget.toke.dk (unknown [10.42.3.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.tohojo.dk (Postfix) with ESMTPSA id EEC4F1EC0619 for ; Sun, 7 Jul 2013 17:55:48 +0200 (CEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi I've been wanting to have support for exporting recurring events to iCal while limiting the number of repetitions, as well as excluding dates. The patch below is my attempt to add this functionality. However, I'm in doubt as to whether or not this is the right way to go about it (parsing dates stored in the property drawer), or if there's a better way? A sample headline supporting this might look like this: * Test :PROPERTIES: :END_DATE: [2013-07-21 Sun] :EXCLUDE: [2013-07-14 Sun] :ID: b376f8e3-f1a7-4ed6-ab9b-a255938af8c0 :END: <2013-07-07 Sun +1w> If this is a reasonable way to go about it, I'll be happy to resubmit it as a proper patch (i.e. from `git format-patch`) for inclusion. :) =2DToke diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index c6ab295..361cef2 100644 =2D-- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -632,6 +632,12 @@ inlinetask within the section." ;; Don't forget components from inner entries. contents)))) =20 +(defun org-icalendar-zero-convert-timestamp (timestamp &optional format) + "Parse and format an org-formatted timestamp, zeroing the time component= ." + (let ((time (org-parse-time-string timestamp)) + (fmt (or format "%Y%m%dT%H%M%SZ"))) + (format-time-string fmt (encode-time 0 0 0 (nth 3 time) (nth 4 time) (= nth 5 time))))) + (defun org-icalendar--vevent (entry timestamp uid summary location description categories) "Create a VEVENT component. @@ -656,11 +662,18 @@ Return VEVENT component as a string." (org-icalendar-convert-timestamp timestamp "DTEND" t) "\n" ;; RRULE. (when (org-element-property :repeater-type timestamp) =2D (format "RRULE:FREQ=3D%s;INTERVAL=3D%d\n" + (format "RRULE:FREQ=3D%s;INTERVAL=3D%d%s\n" (case (org-element-property :repeater-unit timestamp) (hour "HOURLY") (day "DAILY") (week "WEEKLY") (month "MONTHLY") (year "YEARLY")) =2D (org-element-property :repeater-value timestamp))) + (org-element-property :repeater-value timestamp) + (if (not (org-element-property :END_DATE entry)) "" + (format ";UNTIL=3D%s" (org-icalendar-zero-convert-timestamp + (org-element-property :END_DATE entry)))))) + (when (org-element-property :EXCLUDE entry) + (format "EXDATE;VALUE=3DDATE:%s\n" (mapconcat (lambda (ts) (org-ic= alendar-zero-convert-timestamp ts "%Y%m%d")) + (split-string (org-element-property :EXCLUDE entry) ",") + ","))) "SUMMARY:" summary "\n" (and (org-string-nw-p location) (format "LOCATION:%s\n" location)) (and (org-string-nw-p description) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQEcBAEBAgAGBQJR2Y+AAAoJEENeEGz1+utPV3kH/1YmMWSPGXHYczewOb07TLNQ xyp3xURY+S+SY67eLB/2K1eoF6p/lKisOKkqhjtax2E+mAcjUbLNE1qg68k1D+K7 CL/Y7Ce468v2ZBqsZM9MG6wI/tsmAs3R7tY8ZX7UbNPh0O8GYVSeenMEJenclnZc xE8/tUGcyw2QgigCMuHN4WUDIeDftP6HokiTVzk+ntTO41bOLo5K/tRozUgo+1LI pgL+PIRJsfeghFxG5PPpKck0eOG9vquKk+ND4EBxcBvurEC4GzUmRGSsDSDIuzuB uP00HWgiIKQGYITB9fqadM9X43xv7pZq9al57BLb488wi+AWD2wUc2lHXZRylOo= =kueF -----END PGP SIGNATURE----- --=-=-=--