diff --git a/src/trigger.c b/src/trigger.c index 452c69e7..d6b6b787 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -206,16 +206,27 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err) *err = E_BAD_DATE; return -1; } + /* Back up a year in case we'll cross a year boundary*/ + if (y > BASE) { + y--; + } + /* Move up to the first valid year */ while (trig->d > DaysInMonth(trig->m, y)) y++; + /* Try last year */ + j = Julian(y, trig->m, trig->d); + while(! (trig->wd & (1 << (j%7)))) j++; + if (j >= startdate) return j; + /* Try this year */ + y++; j = Julian(y, trig->m, trig->d); while(! (trig->wd & (1 << (j%7)))) j++; if (j >= startdate) return j; /* Must be next year */ - y = y + 1; + y++; while (trig->d > DaysInMonth(trig->m, y)) y++; j = Julian(y, trig->m, trig->d); while(! (trig->wd & (1 << (j%7)))) j++; diff --git a/tests/test-rem b/tests/test-rem index 4664b2ce..2f8abfd5 100644 --- a/tests/test-rem +++ b/tests/test-rem @@ -60,6 +60,8 @@ chmod 644 include_dir/04cantread.rem echo "Color Test" >> ../tests/test.out ../src/remind -ccl ../tests/colors.rem 1 aug 2007 >> ../tests/test.out +echo "MON WKDAY DAY across year test" >> ../tests/test.out +echo 'REM Mon 29 Dec MSG x' | ../src/remind -dt - 1 Jan 2000 >> ../tests/test.out 2>&1 cmp -s ../tests/test.out ../tests/test.cmp if [ "$?" = "0" ]; then echo "Remind: Acceptance test PASSED" diff --git a/tests/test.cmp b/tests/test.cmp index d417a57d..b861cae3 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -2106,4 +2106,6 @@ Color Test (0x(B (0x(B (0x(BBright (0x(B (0x(B (0x(B (0x(B (0x(B (0x(B (0x(B (0x(BWhite (0x(B (0x(B (0x(B (0x(B (0x(B (0mqqqqqqqqqqvqqqqqqqqqqvqqqqqqqqqqvqqqqqqqqqqvqqqqqqqqqqvqqqqqqqqqqvqqqqqqqqqqj(B - \ No newline at end of file + MON WKDAY DAY across year test +-(1): Trig = Monday, 3 January, 2000 +No reminders.