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