summaryrefslogtreecommitdiffstats
path: root/usr.bin/calendar/io.c
diff options
context:
space:
mode:
authormpp <mpp@FreeBSD.org>1996-04-06 01:15:21 +0000
committermpp <mpp@FreeBSD.org>1996-04-06 01:15:21 +0000
commit8c881f139a10b8e4b476c7eb3b080107675722b8 (patch)
tree12dec63aaed993bb230307b1563a63a42da6bdf5 /usr.bin/calendar/io.c
parentecbbba2d2cd1916ea87c2ee41e48d5b94a9529d2 (diff)
downloadFreeBSD-src-8c881f139a10b8e4b476c7eb3b080107675722b8.zip
FreeBSD-src-8c881f139a10b8e4b476c7eb3b080107675722b8.tar.gz
Change calendar to report the actual date for variable day events.
E.g. for Easter, and entries like "04/SunFirst" calendar will now report: 04/05* Good Friday (2 days before easter) 04/07* First Sunday... instead of: Easter-2 Good Friday... 04/SunFirst First Sunday... I also modified the calendar files to use the variable day format for a lot of events so that they will be reported correctly. E.g. U.S. daylight savings time is now listed as: 04/SunFirst Daylight savings time... There are still a lot of wrong dates in there for some events that move from year to year, but I don't have a good calendar handy right now that I can use for reference.
Diffstat (limited to 'usr.bin/calendar/io.c')
-rw-r--r--usr.bin/calendar/io.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 46302de..82c1cd1 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -82,6 +82,9 @@ cal()
register char *p;
FILE *fp;
int ch;
+ int month;
+ int day;
+ int var;
char buf[2048 + 1];
if ((fp = opencal()) == NULL)
@@ -93,10 +96,18 @@ cal()
while ((ch = getchar()) != '\n' && ch != EOF);
if (buf[0] == '\0')
continue;
- if (buf[0] != '\t')
- printing = isnow(buf) ? 1 : 0;
- if (printing)
- (void)fprintf(fp, "%s\n", buf);
+ if (buf[0] != '\t') {
+ printing = isnow(buf, &month, &day, &var) ? 1 : 0;
+ if ((p = strchr(buf, '\t')) == NULL)
+ continue;
+ if (p > buf && p[-1] == '*')
+ var = 1;
+ if (printing)
+ (void)fprintf(fp, "%.2d/%.2d%c%s\n", month,
+ day, var ? '*' : ' ', p);
+ }
+ else if (printing)
+ fprintf(fp, "%s\n", buf);
}
closecal(fp);
}
OpenPOWER on IntegriCloud