* Exporting org-diary-class to icalendar
@ 2010-12-06 19:20 Rémi Vanicat
2011-02-11 9:50 ` Bastien
0 siblings, 1 reply; 2+ messages in thread
From: Rémi Vanicat @ 2010-12-06 19:20 UTC (permalink / raw
To: emacs-orgmode
Hello,
For those who want to use the org-diary-class diary sexp, and who want
to export it to ical (for google calendar consumption for example) Here
is a code that will do it. Beware that my timezone is hardwired in it
(search for Europe/Paris).
For now it doesn't take into account the skipped weeks, my first
implementation seemed to failed for an unknown reason.
--8<---------------cut here---------------start------------->8---
(defun icalendar--convert-org-diary-class-to-ical (nonmarker entry-main)
"Convert `org-diary-class' diary entry to icalendar format.
NONMARKER is a regular expression matching the start of non-marking
entries. ENTRY-MAIN is the first line of the diary entry."
(if (string-match (concat nonmarker
"%%(org-diary-class "
"\\([0-9]+ [0-9]+ [0-9]+\\) " ;date start
"\\([0-9]+ [0-9]+ [0-9]+\\) " ;date start
"\\([0-9]+\\)" ;DAYNAME
"\\([ 0-9]*\\)) "
"\\("
"\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
"\\(-\\([0-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
"\\)?"
"\\s-*\\(.*\\) ?$")
entry-main)
(let* ((start (match-string 1 entry-main))
(end (match-string 2 entry-main))
(dayname (read (match-string 3 entry-main)))
(skip-week (match-string 4 entry-main))
(remain-week ())
(startisostring (icalendar--datestring-to-isodate start))
(endisostring (icalendar--datestring-to-isodate end))
(starttimestring (icalendar--diarytime-to-isotime
(when (match-beginning 6)
(match-string 6 entry-main))
(when (match-beginning 7)
(match-string 7 entry-main))))
(endtimestring (icalendar--diarytime-to-isotime
(when (match-beginning 9)
(match-string 9 entry-main))
(when (match-beginning 10)
(match-string 10 entry-main))))
(summary (icalendar--convert-string-for-export
(match-string 11 entry-main))))
(icalendar--dmsg "org-diary-class %s" entry-main)
(setq skip-week (read (concat "(" skip-week ")")))
(when skip-week
(setq remain-week (number-sequence 1 52))
(mapc (lambda (el) (setq remain-week (delete el remain-week)))
skip-week))
(when starttimestring
(unless endtimestring
(let ((time
(read (icalendar--rris "^T0?" ""
starttimestring))))
(setq endtimestring (format "T%06d"
(+ 10000 time))))))
(list (concat "\nDTSTART;TZID=Europe/Paris;"
(if starttimestring "VALUE=DATE-TIME:"
"VALUE=DATE:")
startisostring
(or starttimestring "")
"\nDTEND;TZID=Europe/Paris;"
(if endtimestring "VALUE=DATE-TIME:"
"VALUE=DATE:")
startisostring
(or endtimestring "")
"\nRRULE:FREQ=DAILY;INTERVAL=1"
";BYDAY="
(nth dayname '("SU" "MO" "TU" "WE" "TH" "FR" "SA"))
";UNTIL="
endisostring)
summary))
;; no match
nil))
(defadvice icalendar--convert-to-ical (around ical-for-org (nonmarker entry-main))
(let ((res (icalendar--convert-org-diary-class-to-ical nonmarker entry-main)))
(if res
(setq ad-return-value res)
ad-do-it)))
(ad-activate 'icalendar--convert-to-ical)
--8<---------------cut here---------------end--------------->8---
--
Rémi Vanicat
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Exporting org-diary-class to icalendar
2010-12-06 19:20 Exporting org-diary-class to icalendar Rémi Vanicat
@ 2011-02-11 9:50 ` Bastien
0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2011-02-11 9:50 UTC (permalink / raw
To: Rémi Vanicat; +Cc: emacs-orgmode
Hi Rémi,
Rémi Vanicat <vanicat@debian.org> writes:
> For those who want to use the org-diary-class diary sexp, and who want
> to export it to ical (for google calendar consumption for example) Here
> is a code that will do it. Beware that my timezone is hardwired in it
> (search for Europe/Paris).
Quite useful. Would you like to publicize it on Worg?
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-11 9:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06 19:20 Exporting org-diary-class to icalendar Rémi Vanicat
2011-02-11 9:50 ` Bastien
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.