--- ../calendar/calendar.c 2014-11-11 12:03:24.000000000 -0800 +++ ./calendar.c 2015-06-22 15:08:19.000000000 -0700 @@ -108,6 +108,7 @@ case 'd': /* debug output of current date */ debug = 1; + debug_remember = 1; break; case 'F': /* Change the time: When does weekend start? */ --- ../calendar/parsedata.c 2014-11-11 12:03:24.000000000 -0800 +++ ./parsedata.c 2015-06-22 03:41:12.000000000 -0700 @@ -576,7 +576,9 @@ /* Every dayofweek of the year */ if (lflags == (F_DAYOFWEEK | F_VARIABLE)) { dow = first_dayofweek_of_year(year); - d = (idayofweek - dow + 8) % 7; + if (dow < 0) + continue; + d = (idayofweek - dow + 7) % 7 + 1; while (d <= 366) { if (remember_yd(year, d, &rm, &rd)) remember(&remindex, @@ -614,7 +616,9 @@ (F_MONTH | F_DAYOFWEEK | F_MODIFIERINDEX | F_VARIABLE)) { offset = indextooffset(modifierindex); dow = first_dayofweek_of_month(year, imonth); - d = (idayofweek - dow + 8) % 7; + if (dow < 0) + continue; + d = (idayofweek - dow + 7) % 7 + 1; if (offset > 0) { while (d <= yearinfo->monthdays[imonth]) { @@ -648,7 +652,9 @@ /* Every dayofweek of the month */ if (lflags == (F_DAYOFWEEK | F_MONTH | F_VARIABLE)) { dow = first_dayofweek_of_month(year, imonth); - d = (idayofweek - dow + 8) % 7; + if (dow < 0) + continue; + d = (idayofweek - dow + 7) % 7 + 1; while (d <= yearinfo->monthdays[imonth]) { if (remember_ymd(year, imonth, d)) remember(&remindex,