1 static char *sccsid = "@(#)calendar.c 4.2 (Berkeley) 81/02/28"; 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 */ 8 #include <time.h> 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); 33 printf("(^|[ (,;])((%s[^ ]* *|%d/)0*%d)([^0123456789]|$)\n", 34 month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday); 35 printf("(^|[ (,;])((\\* *)0*%d)([^0123456789]|$)\n", 36 tm->tm_mday); 37 } 38 39 main() 40 { 41 long t; 42 time(&t); 43 tprint(t); 44 switch(localtime(&t)->tm_wday) { 45 case 5: 46 t += DAY; 47 tprint(t); 48 case 6: 49 t += DAY; 50 tprint(t); 51 default: 52 t += DAY; 53 tprint(t); 54 } 55 } 56