Commit | Line | Data |
---|---|---|
df84ec78 | 1 | static char *sccsid = "@(#)calendar.c 4.6 (Berkeley) 87/05/02"; |
96287344 BJ |
2 | /* /usr/lib/calendar produces an egrep -f file |
3 | that will select today's and tomorrow's | |
4 | calendar entries, with special weekend provisions | |
5 | ||
6 | used by calendar command | |
7 | */ | |
e22d6501 | 8 | #include <sys/time.h> |
96287344 BJ |
9 | |
10 | #define DAY (3600*24L) | |
11 | ||
12 | char *month[] = { | |
13 | "[Jj]an", | |
14 | "[Ff]eb", | |
15 | "[Mm]ar", | |
16 | "[Aa]pr", | |
17 | "[Mm]ay", | |
18 | "[Jj]un", | |
19 | "[Jj]ul", | |
20 | "[Aa]ug", | |
21 | "[Ss]ep", | |
22 | "[Oo]ct", | |
23 | "[Nn]ov", | |
24 | "[Dd]ec" | |
25 | }; | |
26 | struct tm *localtime(); | |
27 | ||
28 | tprint(t) | |
29 | long t; | |
30 | { | |
31 | struct tm *tm; | |
32 | tm = localtime(&t); | |
df84ec78 | 33 | printf("(^|[ \t(,;])((%s[^ \t]*[ \t]*|(0%d|%d)/)0*%d)([^0123456789]|$)\n", |
bdeaa584 BJ |
34 | month[tm->tm_mon], |
35 | tm->tm_mon + 1, tm->tm_mon + 1, tm->tm_mday); | |
df84ec78 | 36 | printf("(^|[ \t(,;])((\\*[ \t]*)0*%d)([^0123456789]|$)\n", |
492e9668 | 37 | tm->tm_mday); |
96287344 BJ |
38 | } |
39 | ||
40 | main() | |
41 | { | |
42 | long t; | |
43 | time(&t); | |
44 | tprint(t); | |
45 | switch(localtime(&t)->tm_wday) { | |
46 | case 5: | |
47 | t += DAY; | |
48 | tprint(t); | |
49 | case 6: | |
50 | t += DAY; | |
51 | tprint(t); | |
52 | default: | |
53 | t += DAY; | |
54 | tprint(t); | |
55 | } | |
56 | } |