1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Let $ical show recurring events that had the first start in the past but have one of the next starts in the future.

Each recurring event is only showed once, maybe i'll change this in the future
This commit is contained in:
Nikolas Garofil 2010-05-25 17:33:55 +02:00
parent 4bc136be88
commit 53b167a84a

View File

@ -49,7 +49,21 @@ struct ical_event *add_event(struct ical_event *listend, icalcomponent *new_ev)
icaltimetype start;
start = icalcomponent_get_dtstart(new_ev);
if(icaltime_compare(start, icaltime_from_timet(time(NULL), 0)) <= 0) return NULL;
if(icaltime_compare(start, icaltime_from_timet(time(NULL), 0)) <= 0) {
icalproperty *rrule = icalcomponent_get_first_property(new_ev, ICAL_RRULE_PROPERTY);
if(rrule) {
icalrecur_iterator* ritr = icalrecur_iterator_new(icalproperty_get_rrule(rrule), start);
icaltimetype nexttime = icalrecur_iterator_next(ritr);
while (!icaltime_is_null_time(nexttime)) {
if(icaltime_compare(nexttime, icaltime_from_timet(time(NULL), 0)) > 0) {
start = nexttime;
break;
}
nexttime = icalrecur_iterator_next(ritr);
}
icalrecur_iterator_free(ritr);
} else return NULL;
}
ev_new = (struct ical_event *) malloc(sizeof(struct ical_event));
memset(ev_new, 0, sizeof(struct ical_event));
ev_new->event = new_ev;