#32 icaltime_add() does not work if is_date is true

open
nobody
None
5
2008-03-18
2008-03-18
Jim Beveridge
No

I am trying to add 1 (one) day to an icaltimetype structure. The code looks like this:

icaltimetype tt = {0};
tt.ical.is_date = true;
tt.year = 2008;
tt.month = 3;
tt.day = 28;
tt.hour = 0;
tt.minute = 0;
tt.second = 0;
tt.is_utc = true;
tt.is_date = true;
tt.is_daylight = false;

struct icaldurationtype d = {0};
d.days = 1;
ical = icaltime_add(ical, d);

The call to icaltime_add doesn't work because icaltime_add increases the number of seconds in tt, but icaltime_adjust ignores the seconds value since is_date is true. So icaltime_add does not work if is_date is true.

The workaround is to use this code, but it would be better if icaltime_add worked properly:
ical.day += 1;
ical = icaltime_normalize(ical);

Discussion