Recurrent Events

Iñigo Martínez inigomartinez at gmail.com
Thu Feb 2 13:30:03 PST 2017


Hello,

Recently I have started working with evolution-data-server to manage
calendar information which by the way uses libical (2.0.0-0.5+b1 on
Debian), so I created some tests programs using its API. I am not able
to handle some recurrent events though.

I have created an event with the following information (the following
output came from the icalcomponent_as_ical_string function):

BEGIN:VEVENT
UID:20170201T132849Z-20707-1000-1-14 at prtgb376
DTSTAMP:20170201T111848Z
DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
 20170201T143000
DTEND;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
 20170201T143000
SEQUENCE:2
SUMMARY:GCal Test
LOCATION:Luna
TRANSP:OPAQUE
CLASS:PUBLIC
CREATED:20170201T132906Z
LAST-MODIFIED:20170202T151933Z
RRULE;X-EVOLUTION-ENDDATE=20170203T133000Z:FREQ=DAILY;COUNT=3
RECURRENCE-ID;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
 20170201T143000
BEGIN:VALARM
X-EVOLUTION-ALARM-UID:20170201T132849Z-20707-1000-1-15 at prtgb376
ACTION:DISPLAY
TRIGGER;VALUE=DURATION;RELATED=START:-PT15M
END:VALARM
END:VEVENT

As you can see the event was created with DTSTART 20170201T143000 and
DTEND 20170201T143000 and the following RRULE
RRULE;X-EVOLUTION-ENDDATE=20170203T133000Z:FREQ=DAILY;COUNT=3. So
following your hints, I used the following code to access all the
recurrent events:

  rrule = icalcomponent_get_first_property(icalcomp, ICAL_RRULE_PROPERTY);
  if (rrule)
    {
      recur = icalproperty_get_rrule (rrule);
      ritr = icalrecur_iterator_new (recur, dtstart);
      for (struct icaltimetype next = icalrecur_iterator_next (ritr);
          !icaltime_is_null_time (next);
          next = icalrecur_iterator_next(ritr))
        {
          t = icaltime_as_timet (next);
          g_print ("  %s", ctime (&t));
        }
      icalrecur_iterator_free(ritr);
    }

Which gives me the following output that fits perfectly what I was expecting:

  Wed Feb  1 15:30:00 2017
  Thu Feb  2 15:30:00 2017
  Fri Feb  3 15:30:00 2017

But when I accessing the event in the day 2, which is the first
recurrent event, I get the following information (the following output
also came from the icalcomponent_as_ical_string function):

BEGIN:VEVENT
UID:20170201T132849Z-20707-1000-1-14 at prtgb376
DTSTAMP:20170201T111848Z
DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
 20170202T143000
DTEND;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
 20170202T150000
SEQUENCE:2
SUMMARY:GCal Test
LOCATION:Luna
TRANSP:OPAQUE
CLASS:PUBLIC
CREATED:20170201T132906Z
LAST-MODIFIED:20170202T151933Z
RRULE;X-EVOLUTION-ENDDATE=20170203T133000Z:FREQ=DAILY;COUNT=3
RECURRENCE-ID;TZID=/freeassociation.sourceforge.net/Europe/Madrid:
 20170202T143000
BEGIN:VALARM
X-EVOLUTION-ALARM-UID:20170201T132849Z-20707-1000-1-15 at prtgb376
ACTION:DISPLAY
TRIGGER;VALUE=DURATION;RELATED=START:-PT15M
END:VALARM
END:VEVENT

When using the same code for accesing the recurrent events I get the
following output:

  Thu Feb  2 15:30:00 2017
  Fri Feb  3 15:30:00 2017
  Sat Feb  4 15:30:00 2017

This output shouldn't be possible as Sat Feb  4 15:30:00 2017 is out
of the time frame. Something similar happens with the third and last
event, with the following output:

  Fri Feb  3 15:30:00 2017
  Sat Feb  4 15:30:00 2017
  Sun Feb  5 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.

So, my question is, what is the proper way to access recurrent events?

Thank you,

Best regards,



More information about the libical-devel mailing list