From: Matt Lundin <mdl@imapmail.org>
To: Julien Cubizolles <j.cubizolles@free.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: using holiday dates from an ICAL calendar
Date: Wed, 12 Aug 2015 16:37:49 -0500 [thread overview]
Message-ID: <87si7o8a3a.fsf@fastmail.fm> (raw)
In-Reply-To: <876153dpjr.fsf@free.fr> (Julien Cubizolles's message of "Wed, 29 Jul 2015 16:08:40 +0200")
Julien Cubizolles <j.cubizolles@free.fr> writes:
> I need to define weekly appointments, except during the school
> holidays. I know org-class provides a way to exclude some weeks from
> recurring events but I was wondering if some clever use of sexp would
> make it possible to use the weeks/days of holiday from a public ical
> calendar (like
> https://www.google.com/calendar/ical/bubn5utkn054pluh4v44nu6ok62e1dbo%40import.calendar.google.com/public/basic.ics).
> Did somebody ever try it ?
One possible solution that comes to mind would be to parse the calendar
with icalendar-import-file.
wget https://www.google.com/calendar/ical/bubn5utkn054pluh4v44nu6ok62e1dbo%40import.calendar.google.com/public/basic.ics /tmp/basic.ics
Then within emacs:
(icalendar-import-file "/tmp/basic.ics" "/tmp/diary")
This produces entries that look like this:
--8<---------------cut here---------------start------------->8---
%%(and (diary-block 10 17 2015 11 1 2015)) Vacances de la Toussaint - Zone B
Desc: Vacances de la Toussaint
Location: Aix-Marseille, Amiens, Caen, Lille, Nancy-Metz, Nantes, Nice, Orléans-Tours, Reims, Rennes, Rouen, Strasbourg
--8<---------------cut here---------------end--------------->8---
You could write a script to parse this data and combine it with an
org-class sexp, resulting in something like this:
%%(and (not (diary-block 10 17 2015 11 1 2015)) (org-class 2015 9 15 2015 12 20 3)) My class
Alternatively you could use the data in the diary block to calculate
which iso weeks to add to the SKIP-WEEKS arguments of org-class, which
has the following form:
(org-class Y1 M1 D1 Y2 M2 D2 DAYNAME &rest SKIP-WEEKS)
Here's a proof of concept that shows how you could quickly calculate
which days to add to org-class. It takes two dates and a day of week
(dow), returning the iso weeks in which the day of the week falls within
the diary block.
--8<---------------cut here---------------start------------->8---
(defun my-calculate-skip-weeks (date1 date2 dow)
(let ((d1 (calendar-absolute-from-gregorian date1))
(d2 (calendar-absolute-from-gregorian date2))
(iso-weeks))
(while (< d1 d2)
(let ((iso-date (calendar-iso-from-absolute d1)))
(when (eq (nth 1 iso-date) dow)
(add-to-list 'iso-weeks (car (calendar-iso-from-absolute d1)) t)))
(setq d1 (1+ d1)))
iso-weeks))
--8<---------------cut here---------------end--------------->8---
Using the diary block information above and taking Wednesday as the day
of the week, the function yields the days of the week to add as
SKIP-WEEKS in org-class:
(my-calculate-skip-weeks '(10 17 2015) '(11 1 2015) 3) => (43 44)
Based on this information, the org-class sexp could be written like
this:
%%(org-class 2015 9 15 2015 12 20 3 43 44) My class
Obviously this would need to be scripted. But I hope these ideas help.
Matt
next prev parent reply other threads:[~2015-08-12 21:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-29 14:08 using holiday dates from an ICAL calendar Julien Cubizolles
2015-08-12 21:37 ` Matt Lundin [this message]
2015-08-27 11:25 ` Julien Cubizolles
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87si7o8a3a.fsf@fastmail.fm \
--to=mdl@imapmail.org \
--cc=emacs-orgmode@gnu.org \
--cc=j.cubizolles@free.fr \
/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 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).