summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-08-29 18:06:53 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-08-29 18:06:53 +0200
commit2f222fde9ff914f7fb68976f6fbbf99e14a8208f (patch)
tree70871c1ad87b2e8dbd6b72d46e9fa33409e45306
parent13e95f9904844fb7e7e406de89e8d48934f9d04f (diff)
downloadsnooze-2f222fde9ff914f7fb68976f6fbbf99e14a8208f.tar.gz
snooze-2f222fde9ff914f7fb68976f6fbbf99e14a8208f.tar.xz
snooze-2f222fde9ff914f7fb68976f6fbbf99e14a8208f.zip
fix dayofyear and weekofyear properly v0.2
-rw-r--r--snooze.14
-rw-r--r--snooze.c6
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;