diff --git a/usr.bin/calendar/calendar.1 b/usr.bin/calendar/calendar.1 index ade4f0f17507..7964e75d4517 100644 --- a/usr.bin/calendar/calendar.1 +++ b/usr.bin/calendar/calendar.1 @@ -56,7 +56,8 @@ utility checks the current directory for a file named .Pa calendar and displays lines that begin with either today's date or tomorrow's. -On Fridays, events on Friday through Monday are displayed. +On the day before a weekend (normally Friday), events for the next +three days are displayed. .Pp The following options are available: .Bl -tag -width Ds @@ -72,6 +73,14 @@ days (forward, future). Print lines from today and the previous .Ar num days (backward, past). +.It Fl F +Specify which day of the week is ``Friday'' (the day before the +weekend begins). +.It Fl W Ar num +Print lines from today and the next +.Ar num +days (forward, future). +Ignore weekends when calculating the number of days. .It Fl f Pa calendarfile Use .Pa calendarfile diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index dc5b6d982147..4f2636248e80 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -64,6 +64,7 @@ time_t f_time = 0; int f_dayAfter = 0; /* days after current date */ int f_dayBefore = 0; /* days before current date */ +int Friday = 5; /* day before weekend */ int main(argc, argv) @@ -74,7 +75,7 @@ main(argc, argv) (void) setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "-af:t:A:B:")) != -1) + while ((ch = getopt(argc, argv, "-af:t:A:B:F:W:")) != -1) switch (ch) { case '-': /* backward contemptible */ case 'a': @@ -94,6 +95,10 @@ main(argc, argv) f_time = Mktime (optarg); break; + case 'W': /* we don't need no steenking Fridays */ + Friday = -1; + + /* FALLTHROUGH */ case 'A': /* days after current date */ f_dayAfter = atoi(optarg); break; @@ -102,6 +107,10 @@ main(argc, argv) f_dayBefore = atoi(optarg); break; + case 'F': + Friday = atoi(optarg); + break; + case '?': default: usage(); @@ -137,7 +146,8 @@ void usage() { (void)fprintf(stderr, - "usage: calendar [-a] [-A days] [-B days] [-f calendarfile] [-t dd[.mm[.year]]]\n"); + "usage: calendar [-a] [-A days] [-W days] [-F friday] [-B days]\n" + "\t[-f calendarfile] [-t dd[.mm[.year]]]\n"); exit(1); } diff --git a/usr.bin/calendar/calendar.h b/usr.bin/calendar/calendar.h index 08cbb942f488..0dbd376a10e0 100644 --- a/usr.bin/calendar/calendar.h +++ b/usr.bin/calendar/calendar.h @@ -67,6 +67,7 @@ void setnnames(void); extern int f_dayAfter; /* days after current date */ extern int f_dayBefore; /* days bevore current date */ +extern int Friday; /* day before weekend */ struct fixs { char *name; diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 3f8ab25a3ab5..c1da370e9d73 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -150,7 +150,7 @@ settime(now) cumdays = daytab[0]; } /* Friday displays Monday's events */ - offset = tp->tm_wday == 5 ? 3 : 1; + offset = tp->tm_wday == Friday ? 3 : 1; header[5].iov_base = dayname; oldl = NULL;