Recurrent Events
Iñigo Martínez
inigomartinez at gmail.com
Fri Feb 3 01:49:19 PST 2017
Thank you for your support Milan.
I have tried the following. I checked if the ECalClient has support
for master object on recurrences using
e_cal_client_check_recurrences_no_master() and the result is 0, so I
should check if an icalcomponent is not master object in order to
ignore the RRULE. Is this correct? If it is, the next question would
be, how do I get the master object of a recurrent event? I tried
icalcomponent_get_parent() without any success as the recurrent events
return no parent.
I tried the second approach also, the one using the
e_cal_recur_generate_instances_sync(). I used it in the following way.
First I called e_cal_client_generate_instances:
e_cal_client_generate_instances (client, start, end, NULL,
e_cal_instances_cb, client, NULL);
Where I used a wide time frame to generate instances for the events
involved in the recurrence (start = 2017-01-29 00:00:00, end =
2017-02-10 00:00:00).
Then on e_cal_instances_cb(), for every involved event (master and
recurrent events), I call to e_cal_recur_generate_instances_sync():
e_cal_recur_generate_instances_sync (icalcomp, dtstart, last,
recur_generate_cb, NULL, recur_generate_tz_cb, NULL, tz, NULL,
&error);
Again, I used a wide time frame to check for the recurrent events so I
don't miss any of them, so I actually I'm using the following dates
and I am getting the following results:
The one I consider the first/master recurrent event:
instance start: Wed Feb 1 14:30:00 2017
instance end: Wed Feb 1 15:00:00 2017
dstart: Tue Jan 31 15:30:00 2017
last: Sat Feb 4 15:30:00 2017
recur_generate_cb_start: Wed Feb 1 15:30:00 2017
recur_generate_cb_end: Wed Feb 1 16:00:00 2017
For the second recurrent event (not the master event):
instance start: Thu Feb 2 14:30:00 2017
instance end: Thu Feb 2 15:00:00 2017
recurrence start: Wed Feb 1 15:30:00 2017
recurrence end: Sun Feb 5 15:30:00 2017
recur_generate_cb_start: Thu Feb 2 15:30:00 2017
recur_generate_cb_end: Thu Feb 2 16:00:00 2017
For the last recurrent event (not the master also):
instance start: Fri Feb 3 14:30:00 2017
instance end: Fri Feb 3 15:00:00 2017
recurrence start: Thu Feb 2 15:30:00 2017
recurrence end: Mon Feb 6 15:30:00 2017
recur_generate_cb_start: Fri Feb 3 15:30:00 2017
recur_generate_cb_end: Fri Feb 3 16:00:00 2017
Actually those results aren't what I was expecting. I was expecting
three calls to recur_generate_cb using the first/master recurrent
event, two calls to recur_generate_cb in the second recurrent event,
and just one call to recur_generate_cb on the last recurrent event.
Seems that I'm missing something or that I'm doing something expecting
a different result.
What should be the proper way to get a similar behaviour?
I have been watching the gnome-calendar code, but I'm not sure if
recurrent events are fully supported.
Best regards,
2017-02-03 9:48 GMT+01:00 Milan Crha <mcrha at redhat.com>:
> 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
>
> _______________________________________________
> libical-devel mailing list
> libical-devel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libical-devel
More information about the libical-devel
mailing list