Date: Fri, 10 Apr 2020 22:18:13 +0000 (UTC) From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359782 - in stable/12/usr.bin/calendar: . calendars tests Message-ID: <202004102218.03AMIDLJ018399@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gonzo Date: Fri Apr 10 22:18:13 2020 New Revision: 359782 URL: https://svnweb.freebsd.org/changeset/base/359782 Log: MFC r359585, r359587 r359585: Fix calculation of the recurring weekdays Both the result of the first_dayofweek_of_year and the target weekday are zero-based (0 fo sunday) while the target month-day or year-day is 1-based. Adjust logic accordingly. Also add testcase for this PR to the kyua test suite PR: 201062 Submitted by: Richard Narron <comet.berkeley@gmail.com> r359587: Remove hardcoded US Election Day from calendar.usholiday calendar(1) syntax is not capable of representing the rules for the US Election Day. The hardcoded date was set in r15066 in 1996 and hasn't changed since then. PR: 173389 Reported by: Steve Ames <steve@energistic.com> Added: stable/12/usr.bin/calendar/tests/regress.s5.out - copied unchanged from r359585, head/usr.bin/calendar/tests/regress.s5.out Modified: stable/12/usr.bin/calendar/calendars/calendar.usholiday stable/12/usr.bin/calendar/parsedata.c stable/12/usr.bin/calendar/tests/calendar.calibrate stable/12/usr.bin/calendar/tests/regress.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/calendar/calendars/calendar.usholiday ============================================================================== --- stable/12/usr.bin/calendar/calendars/calendar.usholiday Fri Apr 10 21:27:49 2020 (r359781) +++ stable/12/usr.bin/calendar/calendars/calendar.usholiday Fri Apr 10 22:18:13 2020 (r359782) @@ -30,7 +30,6 @@ 09/22* Autumnal Equinox 10/MonSecond Columbus Day in USA (2nd Monday of October) 10/31 All Hallows Eve (Halloween) -11/05* Election Day in USA (1st Tuesday after 1st Monday for even years) 11/SunFirst Daylight Savings Time ends in USA; clocks move back (1st Sunday of November) 11/11 Veterans' Day 11/ThuFourth Thanksgiving Day (4th Thursday in November) Modified: stable/12/usr.bin/calendar/parsedata.c ============================================================================== --- stable/12/usr.bin/calendar/parsedata.c Fri Apr 10 21:27:49 2020 (r359781) +++ stable/12/usr.bin/calendar/parsedata.c Fri Apr 10 22:18:13 2020 (r359782) @@ -578,7 +578,9 @@ parsedaymonth(char *date, int *yearp, int *monthp, int /* 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, @@ -616,7 +618,9 @@ parsedaymonth(char *date, int *yearp, int *monthp, int (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]) { @@ -650,7 +654,9 @@ parsedaymonth(char *date, int *yearp, int *monthp, int /* 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, Modified: stable/12/usr.bin/calendar/tests/calendar.calibrate ============================================================================== --- stable/12/usr.bin/calendar/tests/calendar.calibrate Fri Apr 10 21:27:49 2020 (r359781) +++ stable/12/usr.bin/calendar/tests/calendar.calibrate Fri Apr 10 22:18:13 2020 (r359782) @@ -188,6 +188,7 @@ LANG=C 06/28 jun 28 06/29 jun 29 06/30 jun 30 +06/SunThird sunthird 07/01 jul 1 07/02 jul 2 07/03 jul 3 Copied: stable/12/usr.bin/calendar/tests/regress.s5.out (from r359585, head/usr.bin/calendar/tests/regress.s5.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/calendar/tests/regress.s5.out Fri Apr 10 22:18:13 2020 (r359782, copy of r359585, head/usr.bin/calendar/tests/regress.s5.out) @@ -0,0 +1,3 @@ +Jun 21* sunthird +Jun 21 jun 21 +Jun 22 jun 22 Modified: stable/12/usr.bin/calendar/tests/regress.sh ============================================================================== --- stable/12/usr.bin/calendar/tests/regress.sh Fri Apr 10 21:27:49 2020 (r359781) +++ stable/12/usr.bin/calendar/tests/regress.sh Fri Apr 10 22:18:13 2020 (r359782) @@ -7,12 +7,13 @@ CALENDAR="${CALENDAR_BIN} ${CALENDAR_FILE}" REGRESSION_START($1) -echo 1..28 +echo 1..29 REGRESSION_TEST(`s1',`$CALENDAR -t 29.12.2006') REGRESSION_TEST(`s2',`$CALENDAR -t 30.12.2006') REGRESSION_TEST(`s3',`$CALENDAR -t 31.12.2006') REGRESSION_TEST(`s4',`$CALENDAR -t 01.01.2007') +REGRESSION_TEST(`s5',`$CALENDAR -t 21.06.2015') REGRESSION_TEST(`a1',`$CALENDAR -A 3 -t 28.12.2006') REGRESSION_TEST(`a2',`$CALENDAR -A 3 -t 29.12.2006')
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004102218.03AMIDLJ018399>