cal: check biggest week number correctly when highlighting

This allows Sunday based week 54 be highlighted, and deny week 54 for
Monday based weeks when year has only 52 weeks.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2015-08-27 14:21:29 +01:00 committed by Karel Zak
parent e1abe57e18
commit 03f8bc1f32
3 changed files with 47 additions and 1 deletions

View File

@ -484,7 +484,7 @@ int main(int argc, char **argv)
ctl.req.year, ctl.req.week);
while (m <= DECEMBER && yday > days_in_month[leap][m])
yday -= days_in_month[leap][m++];
if (m > DECEMBER) {
if (DECEMBER < m && ctl.weektype & WEEK_NUM_ISO) {
/* In some years (e.g. 2010 in ISO mode) it's possible
* to have a remnant of week 53 starting the year yet
* the year in question ends during 52, in this case

View File

@ -125,3 +125,23 @@ Julian - Monday-based, week 40 with colors, 3 month
38 259 260 261 262 263 264 265 43 294 295 296 297 298 299 300 47 322 323 324 325 326 327 328
39 266 267 268 269 270 271 272 44 301 302 303 304 48 329 330 331 332 333 334
40 273
Gregorian - Sunday-based, week 54 with colors, 3 month
November 2000 December 2000 January 2001
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
45 1 2 3 4 49 1 2 1 1 2 3 4 5 6
46 5 6 7 8 9 10 11 50 3 4 5 6 7 8 9 2 7 8 9 10 11 12 13
47 12 13 14 15 16 17 18 51 10 11 12 13 14 15 16 3 14 15 16 17 18 19 20
48 19 20 21 22 23 24 25 52 17 18 19 20 21 22 23 4 21 22 23 24 25 26 27
49 26 27 28 29 30 53 24 25 26 27 28 29 30 5 28 29 30 31
54 31
Gregorian - Monday-based, week 53 with colors, 3 month
cal: illegal week value: year 2000 doesn't have week 53
Gregorian - Monday-based, week 52 with colors, 3 month
November 2000 December 2000 January 2001
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
44 1 2 3 4 5 48 1 2 3 1 1 2 3 4 5 6 7
45 6 7 8 9 10 11 12 49 4 5 6 7 8 9 10 2 8 9 10 11 12 13 14
46 13 14 15 16 17 18 19 50 11 12 13 14 15 16 17 3 15 16 17 18 19 20 21
47 20 21 22 23 24 25 26 51 18 19 20 21 22 23 24 4 22 23 24 25 26 27 28
48 27 28 29 30 52 25 26 27 28 29 30 31 5 29 30 31

View File

@ -129,5 +129,31 @@ if [ "$USETERM" == "yes" ]; then
fi
$TS_CMD_CAL -3mj $WEEK $MYTIME >> $TS_OUTPUT
MYTIME="31 12 2000"
PWEEK="week 54 with colors"
WEEK="--week=54 --color=always"
ts_log "Gregorian - Sunday-based, $PWEEK, 3 month $x"
if [ "$USETERM" == "yes" ]; then
$TS_CMD_CAL --three --sunday $WEEK $MYTIME
fi
$TS_CMD_CAL --three --sunday $WEEK $MYTIME >> $TS_OUTPUT
PWEEK="week 53 with colors"
WEEK="--week=53 --color=always"
ts_log "Gregorian - Monday-based, $PWEEK, 3 month $x"
if [ "$USETERM" == "yes" ]; then
$TS_CMD_CAL --three --monday $WEEK $MYTIME
fi
$TS_CMD_CAL --three --monday $WEEK $MYTIME >> $TS_OUTPUT 2>&1
PWEEK="week 52 with colors"
WEEK="--week=52 --color=always"
ts_log "Gregorian - Monday-based, $PWEEK, 3 month $x"
if [ "$USETERM" == "yes" ]; then
$TS_CMD_CAL --three --monday $WEEK $MYTIME
fi
$TS_CMD_CAL --three --monday $WEEK $MYTIME >> $TS_OUTPUT 2>&1
ts_finalize