From 2f222fde9ff914f7fb68976f6fbbf99e14a8208f Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Tue, 29 Aug 2017 18:06:53 +0200 Subject: fix dayofyear and weekofyear properly --- snooze.1 | 4 ++-- snooze.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/snooze.1 b/snooze.1 index bce81ce..1d4c68e 100644 --- a/snooze.1 +++ b/snooze.1 @@ -72,9 +72,9 @@ month .It Fl w weekday (0-7, sunday is 0 and 7) .It Fl D -day of year +day of year (1..366) .It Fl W -ISO week of year (0..53) +ISO week of year (1..53) .It Fl H hour .It Fl M diff --git a/snooze.c b/snooze.c index dfec5c8..3811977 100644 --- a/snooze.c +++ b/snooze.c @@ -142,7 +142,7 @@ parse(char *expr, char *buf, long bufsiz, int offset) char weekday[8] = {0}; char dayofmonth[31] = {0}; char month[12] = {0}; -char dayofyear[366] = {0}; +char dayofyear[367] = {0}; char weekofyear[54] = {0}; char hour[24] = {0}; char minute[60] = {0}; @@ -171,7 +171,7 @@ next_day: while (!(weekday[tm->tm_wday] == '*' && dayofmonth[tm->tm_mday-1] == '*' && month[tm->tm_mon] == '*' - && weekofyear[isoweek(tm)] == '*' + && weekofyear[isoweek(tm)-1] == '*' && dayofyear[tm->tm_yday] == '*')) { if (month[tm->tm_mon] != '*') { // if month is not good, step month @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) while ((c = getopt(argc, argv, "+D:W:H:M:S:T:R:d:m:ns:t:vw:")) != -1) switch(c) { case 'D': parse(optarg, dayofyear, sizeof dayofyear, -1); break; - case 'W': parse(optarg, weekofyear, sizeof weekofyear, 0); break; + case 'W': parse(optarg, weekofyear, sizeof weekofyear, -1); break; case 'H': parse(optarg, hour, sizeof hour, 0); break; case 'M': parse(optarg, minute, sizeof minute, 0); break; case 'S': parse(optarg, second, sizeof second, 0); break; -- cgit 1.4.1