Recurrent Events
Milan Crha
mcrha at redhat.com
Fri Feb 3 00:48:13 PST 2017
On Thu, 2017-02-02 at 22:30 +0100, Iñigo Martínez wrote:
> DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
> 20170201T143000
> DTEND;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
> 20170201T143000
> RRULE;X-EVOLUTION-ENDDATE=20170203T133000Z:FREQ=DAILY;COUNT=3
> RECURRENCE-ID;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
> 20170201T143000
>
> ...
>
> Wed Feb 1 15:30:00 2017
> Thu Feb 2 15:30:00 2017
> Fri Feb 3 15:30:00 2017
>
> ...
>
> DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
> 20170202T143000
> DTEND;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
> 20170202T150000
> RRULE;X-EVOLUTION-ENDDATE=20170203T133000Z:FREQ=DAILY;COUNT=3
> RECURRENCE-ID;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
> 20170202T143000
>
> ...
>
> Thu Feb 2 15:30:00 2017
> Fri Feb 3 15:30:00 2017
> Sat Feb 4 15:30:00 2017
>
> ...
>
> I do always get three events that fits FREQ=DAILY;COUNT=3 rule, but,
> I don't understand why I do get dates after the ENDDATE which is
> 20170203T133000Z.
>
> I tried using icalcomponent_foreach_recurrence functions which uses a
> callback function, but it behaves in the same way.
Hi,
the DTSTART and DTEND define when the first occurrence happens, from
which are calculated following occurrences based on the RRULE. Note
that your events contain RECURRENCE-ID, which means they are an
instance of the recurrence already, might be even a detached instance
(usually a modified instance of the series). Thus to use the RRULE you
should only calculate with the master object, that is the one without
the RECURRENCE-ID. Otherwise the RRULE/RDATE/EXDATE/... are just
informative.
The X-EVOLUTION-ENDDATE, which you refer to, is known only to the
evolution-data-server and it's only a hint. Libical has no idea about
that property parameter, also because it's an "X-" parameter.
> So, my question is, what is the proper way to access recurrent
> events?
As long as you use evolution-data-server, I suggest to give a try to
libecal/e-cal-recur.h functions, namely
e_cal_recur_generate_instances_sync(). Depending what you are targeting
to, maybe consider also reusing ECalDataModel [1], which does many good
things. It's used by the gnome-calendar too.
Bye,
Milan
[1] https://git.gnome.org/browse/evolution/tree/src/calendar/gui/e-cal-data-model.c
More information about the libical-devel
mailing list