diff options
author | Ken Murchison <murch@andrew.cmu.edu> | 2014-09-24 09:22:11 -0400 |
---|---|---|
committer | Ken Murchison <murch@andrew.cmu.edu> | 2014-09-24 09:22:11 -0400 |
commit | 59f4c9e6cbfae58fc7cd62a3dcb5d8a3c242c10c (patch) | |
tree | 8b0f4d73f3ee217b3d30d7aede92de19134b023f | |
parent | 41cf7ba065252bfad2282d8db7382c1d03ec5668 (diff) | |
download | libical-git-59f4c9e6cbfae58fc7cd62a3dcb5d8a3c242c10c.tar.gz |
icalrecur.c: properly skip bogus dates (e.g. 2/29) in RRULE:FREQ=YEARLY[;BYMONTH][;BYMONTHDAY]
-rw-r--r-- | src/libical/icalrecur.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c index 4af68e46..9510ac82 100644 --- a/src/libical/icalrecur.c +++ b/src/libical/icalrecur.c @@ -1955,6 +1955,8 @@ static int iso_week_number(icalrecur_iterator* impl, struct icaltimetype tt) return week; } +#define is_bogus_date(tt) (tt.day > icaltime_days_in_month(tt.month, tt.year)) + /* For INTERVAL=YEARLY, set up the days[] array in the iterator to list all of the days of the current year that are specified in this @@ -2031,7 +2033,9 @@ static int expand_year_days(icalrecur_iterator* impl, int year) t = impl->dtstart; t.year = impl->last.year; - impl->days[days_index++] = (short)icaltime_day_of_year(t); + if (!is_bogus_date(t)) { + impl->days[days_index++] = (short)icaltime_day_of_year(t); + } break; } @@ -2047,10 +2051,11 @@ static int expand_year_days(icalrecur_iterator* impl, int year) t.month = month; t.is_date = 1; - doy = icaltime_day_of_year(t); + if (!is_bogus_date(t)) { + doy = icaltime_day_of_year(t); - impl->days[days_index++] = (short)doy; - + impl->days[days_index++] = (short)doy; + } } break; } @@ -2067,10 +2072,11 @@ static int expand_year_days(icalrecur_iterator* impl, int year) t.year = year; t.is_date = 1; - doy = icaltime_day_of_year(t); - - impl->days[days_index++] = (short)doy; + if (!is_bogus_date(t)) { + doy = icaltime_day_of_year(t); + impl->days[days_index++] = (short)doy; + } } break; } @@ -2090,10 +2096,11 @@ static int expand_year_days(icalrecur_iterator* impl, int year) t.year = year; t.is_date = 1; - doy = icaltime_day_of_year(t); - - impl->days[days_index++] = (short)doy; + if (!is_bogus_date(t)) { + doy = icaltime_day_of_year(t); + impl->days[days_index++] = (short)doy; + } } } |