diff options
author | Ken Murchison <murch@fastmail.com> | 2021-03-18 13:18:12 -0400 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2021-04-11 14:29:32 -0400 |
commit | 18db00b1e945832761dd8080e1f6b67a05bfc2df (patch) | |
tree | 00d0c04a5779c2e5e32eb971bc55c47d1b7117b1 | |
parent | c369ee6c2b57dd6b4212ab456e22a48ddcd713e4 (diff) | |
download | libical-git-18db00b1e945832761dd8080e1f6b67a05bfc2df.tar.gz |
icaltz-util.c: create a macro to wrap icalrecurrencetype_encode_day() - for easier backporting to 3.0
-rw-r--r-- | src/libical/icaltz-util.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libical/icaltz-util.c b/src/libical/icaltz-util.c index 6a45699e..baa5d5ef 100644 --- a/src/libical/icaltz-util.c +++ b/src/libical/icaltz-util.c @@ -263,6 +263,8 @@ static char *parse_posix_zone(char *p, ttinfo *type) return p; } +#define nth_weekday(week, day) (icalrecurrencetype_encode_day(day, week)) + static char *parse_posix_rule(char *p, struct icalrecurrencetype *recur, icaltimetype *t) { @@ -338,7 +340,7 @@ static char *parse_posix_rule(char *p, recur->freq = ICAL_YEARLY_RECURRENCE; if (month) { - recur->by_day[0] = icalrecurrencetype_encode_day((day % 7) + 1, week); + recur->by_day[0] = nth_weekday(week, (day % 7) + 1); recur->by_month[0] = month; if (monthday) { @@ -384,7 +386,6 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) size_t i, num_trans, num_chars, num_leaps, num_isstd, num_isgmt; size_t num_types = 0; size_t size; - int pos, sign; time_t now = time(NULL); int trans_size = 4; @@ -720,9 +721,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) last_trans = 1; } else { - pos = calculate_pos(icaltime); - pos < 0 ? (sign = -1): (sign = 1); - by_day = sign * ((abs(pos) * 8) + icaltime_day_of_week(icaltime)); + by_day = nth_weekday(calculate_pos(icaltime), icaltime_day_of_week(icaltime)); } if (types[idx].isdst) { |