* using holiday dates from an ICAL calendar
@ 2015-07-29 14:08 Julien Cubizolles
2015-08-12 21:37 ` Matt Lundin
0 siblings, 1 reply; 3+ messages in thread
From: Julien Cubizolles @ 2015-07-29 14:08 UTC (permalink / raw)
To: emacs-orgmode
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 ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: using holiday dates from an ICAL calendar
2015-07-29 14:08 using holiday dates from an ICAL calendar Julien Cubizolles
@ 2015-08-12 21:37 ` Matt Lundin
2015-08-27 11:25 ` Julien Cubizolles
0 siblings, 1 reply; 3+ messages in thread
From: Matt Lundin @ 2015-08-12 21:37 UTC (permalink / raw)
To: Julien Cubizolles; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: using holiday dates from an ICAL calendar
2015-08-12 21:37 ` Matt Lundin
@ 2015-08-27 11:25 ` Julien Cubizolles
0 siblings, 0 replies; 3+ messages in thread
From: Julien Cubizolles @ 2015-08-27 11:25 UTC (permalink / raw)
To: emacs-orgmode
Matt Lundin <mdl@imapmail.org> writes:
> (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
I want to use the result of my-calculate-skip-weeks several times.
(my-calculate-skip-weeks) is run from an emacs-lisp source block. I
tried:
--8<---------------cut here---------------start------------->8---
(setq my-holidays '(43 44))
%%(org-class 2015 9 15 2015 12 20 3 'my-holidays') My class
--8<---------------cut here---------------end--------------->8---
but the entry isn't picked up by the agenda. Also, could org-class
access directly the #+RESULTS value if it's named ?
Julien.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-27 11:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-29 14:08 using holiday dates from an ICAL calendar Julien Cubizolles
2015-08-12 21:37 ` Matt Lundin
2015-08-27 11:25 ` Julien Cubizolles
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).