Bell 32V development
authorTom London <tbl@research.uucp>
Mon, 6 Nov 1978 12:17:50 +0000 (07:17 -0500)
committerTom London <tbl@research.uucp>
Mon, 6 Nov 1978 12:17:50 +0000 (07:17 -0500)
Work on file usr/src/cmd/calendar/calendar.c

Co-Authored-By: John Reiser <jfr@research.uucp>
Synthesized-from: 32v

usr/src/cmd/calendar/calendar.c [new file with mode: 0644]

diff --git a/usr/src/cmd/calendar/calendar.c b/usr/src/cmd/calendar/calendar.c
new file mode 100644 (file)
index 0000000..35ca4e3
--- /dev/null
@@ -0,0 +1,52 @@
+/* /usr/lib/calendar produces an egrep -f file
+   that will select today's and tomorrow's
+   calendar entries, with special weekend provisions
+
+   used by calendar command
+*/
+#include <time.h>
+
+#define DAY (3600*24L)
+
+char *month[] = {
+       "[Jj]an",
+       "[Ff]eb",
+       "[Mm]ar",
+       "[Aa]pr",
+       "[Mm]ay",
+       "[Jj]un",
+       "[Jj]ul",
+       "[Aa]ug",
+       "[Ss]ep",
+       "[Oo]ct",
+       "[Nn]ov",
+       "[Dd]ec"
+};
+struct tm *localtime();
+
+tprint(t)
+long t;
+{
+       struct tm *tm;
+       tm = localtime(&t);
+       printf("(^|[ (,;])((%s[^ ]* *|%d/)0*%d)([^0123456789]|$)\n",
+               month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday);
+}
+
+main()
+{
+       long t;
+       time(&t);
+       tprint(t);
+       switch(localtime(&t)->tm_wday) {
+       case 5:
+               t += DAY;
+               tprint(t);
+       case 6:
+               t += DAY;
+               tprint(t);
+       default:
+               t += DAY;
+               tprint(t);
+       }
+}