From: Bill Joy Date: Sun, 1 Mar 1981 12:45:55 +0000 (-0800) Subject: date and time created 81/02/28 20:45:55 by wnj X-Git-Tag: BSD-4_1_snap-Snapshot-Development~2021 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/96287344888419f2345ade331280d106dca19fba?ds=inline date and time created 81/02/28 20:45:55 by wnj SCCS-vsn: usr.bin/calendar/calendar.c 4.1 --- diff --git a/usr/src/usr.bin/calendar/calendar.c b/usr/src/usr.bin/calendar/calendar.c new file mode 100644 index 0000000000..60bcead326 --- /dev/null +++ b/usr/src/usr.bin/calendar/calendar.c @@ -0,0 +1,53 @@ +static char *sccsid = "@(#)calendar.c 4.1 (Berkeley) 81/02/28"; +/* /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 + +#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); + } +}