summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Murchison <murch@fastmail.com>2021-03-15 16:29:11 -0400
committerAllen Winter <allen.winter@kdab.com>2021-04-11 14:27:52 -0400
commitc8b8eb096ed90d4f023d7e68ccba6db31758f84f (patch)
treefac141c70035f936e0786f4ea4683ebd94329c2c
parentaea5834e07e45edc7d72173a4fbaaec98b170ee5 (diff)
downloadlibical-git-c8b8eb096ed90d4f023d7e68ccba6db31758f84f.tar.gz
icaltz-util.c: properly handle non-month-based POSIX rules
-rw-r--r--src/libical/icaltz-util.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libical/icaltz-util.c b/src/libical/icaltz-util.c
index 8ec85bf8..ceca7fbf 100644
--- a/src/libical/icaltz-util.c
+++ b/src/libical/icaltz-util.c
@@ -293,8 +293,10 @@ static char *parse_posix_rule(char *p,
else {
/* The zero-based Julian day (0 <= n <= 365).
Leap days shall be counted, and it is possible to refer to February 29.
+
+ Flag this by adding 1001 to the day.
*/
- /* XXX Currently not used by any zone */
+ day = strtol(++p, &p, 10) + 1001;
}
/* Parse time */
@@ -320,7 +322,9 @@ static char *parse_posix_rule(char *p,
}
if (month) {
if (week == -1) {
- monthday = icaltime_days_in_month(month, -1) + days_adjust - 7;
+ int days_in_month = icaltime_days_in_month(month, 1 /* non-leap */);
+
+ monthday = days_in_month + days_adjust - 7;
}
else {
monthday = 1 + (week - 1) * 7 + days_adjust;
@@ -344,8 +348,15 @@ static char *parse_posix_rule(char *p,
}
}
}
+ else if (day > 1000) {
+ recur->by_year_day[0] = day - 1000;
+ }
else {
- recur->by_year_day[0] = day;
+ /* Convert day-of-non-leap-year into month/day */
+ icaltimetype t = icaltime_from_day_of_year(day, 1 /* non-leap */);
+
+ recur->by_month[0] = t.month;
+ recur->by_month_day[0] = t.day;
}
return p;