diff options
author | mpp <mpp@FreeBSD.org> | 1996-04-06 01:15:21 +0000 |
---|---|---|
committer | mpp <mpp@FreeBSD.org> | 1996-04-06 01:15:21 +0000 |
commit | 8c881f139a10b8e4b476c7eb3b080107675722b8 (patch) | |
tree | 12dec63aaed993bb230307b1563a63a42da6bdf5 /usr.bin/calendar/day.c | |
parent | ecbbba2d2cd1916ea87c2ee41e48d5b94a9529d2 (diff) | |
download | FreeBSD-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/day.c')
-rw-r--r-- | usr.bin/calendar/day.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 427af3d..6a3833e 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -85,7 +85,7 @@ settime(now) } /* convert Day[/Month][/Year] into unix time (since 1970) - * Day: tow digits, Month: two digits, Year: digits + * Day: two digits, Month: two digits, Year: digits */ time_t Mktime (date) char *date; @@ -143,8 +143,11 @@ time_t Mktime (date) * along with the matched line. */ int -isnow(endp) +isnow(endp, monthp, dayp, varp) char *endp; + int *monthp; + int *dayp; + int *varp; { int day, flags, month, v1, v2; @@ -207,6 +210,7 @@ isnow(endp) if (flags & F_ISMONTH) { day = v1; month = v2; + *varp = 0; } /* {Month} {Weekday,Day} ... */ @@ -215,6 +219,7 @@ isnow(endp) month = v1; /* if no recognizable day, assume the first */ day = v2 ? v2 : 1; + *varp = 0; } } @@ -227,6 +232,7 @@ isnow(endp) fprintf(stderr, "\nday: %d %s month %d\n", day, endp, month); #endif + *varp = 1; /* variable weekday, SundayLast, MondayFirst ... */ if (day < 0 || day >= 10) { @@ -270,14 +276,25 @@ isnow(endp) /* wired */ else { day = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7); + *varp = 1; } } #if DEBUG fprintf(stderr, "day2: yday %d %d\n", day, tp->tm_yday); #endif - if (!(flags & F_EASTER)) + if (!(flags & F_EASTER)) { + *monthp = month; + *dayp = day; day = cumdays[month] + day; + } + else { + for (v1 = 0; day > cumdays[v1]; v1++) + ; + *monthp = v1 - 1; + *dayp = day - cumdays[v1 - 1] - 1; + *varp = 1; + } /* if today or today + offset days */ if (day >= tp->tm_yday - f_dayBefore && |