summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>2002-06-13 21:20:56 +0000
committergrog <grog@FreeBSD.org>2002-06-13 21:20:56 +0000
commitfb4608bacb1fa1b6e9fdd02c47d034721446b29f (patch)
tree81000a9a25491407feed68f791095ce654acdc77 /usr.bin
parent0c70e00d001ba34a2608c2b21750c330782350bd (diff)
downloadFreeBSD-src-fb4608bacb1fa1b6e9fdd02c47d034721446b29f.zip
FreeBSD-src-fb4608bacb1fa1b6e9fdd02c47d034721446b29f.tar.gz
Add two new options:
-W is like -A (number of days in the future to consider, but also specifies that we don't want special treatment at weekends. -F changes our notion of "Friday" (the day before the weekend). Arguably, calendar(1) is broken to have special treatment of weekends by default, but this method maintains POLA.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/calendar/calendar.111
-rw-r--r--usr.bin/calendar/calendar.c14
-rw-r--r--usr.bin/calendar/calendar.h1
-rw-r--r--usr.bin/calendar/day.c2
4 files changed, 24 insertions, 4 deletions
diff --git a/usr.bin/calendar/calendar.1 b/usr.bin/calendar/calendar.1
index ade4f0f..7964e75 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 dc5b6d9..4f26362 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 08cbb94..0dbd376 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 3f8ab25..c1da370 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;
OpenPOWER on IntegriCloud