From 9d0a521e31a7492f1469af85891013437e005007 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Fri, 10 May 1996 19:31:02 +0000 Subject: [PATCH] Localize even more. FIx Orthodox Easter calculation Better debug output --- usr.bin/calendar/day.c | 15 ++++----------- usr.bin/calendar/io.c | 20 +++++++++++++++++--- usr.bin/calendar/paskha.c | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 0a5ff8f816b9..210e8d37fa76 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -101,10 +101,6 @@ void setnnames(void) free(fndays[i].name); fndays[i].name = strdup(buf); fndays[i].len = strlen(buf); -#ifdef DEBUG - printf("ndays[%d] = %s, fndays[%d] = %s\n", - i, ndays[i].name, i, fndays[i].name); -#endif } for (i = 0; i < 12; i++) { @@ -130,10 +126,6 @@ void setnnames(void) free(fnmonths[i].name); fnmonths[i].name = strdup(buf); fnmonths[i].len = strlen(buf); -#ifdef DEBUG - printf("nmonths[%d] = %s, fnmonths[%d] = %s\n", - i, nmonths[i].name, i, fnmonths[i].name); -#endif } } @@ -177,6 +169,7 @@ time_t Mktime (date) tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 0; + tm.tm_wday = 0; tm.tm_mday = tp->tm_mday; tm.tm_mon = tp->tm_mon; tm.tm_year = tp->tm_year; @@ -356,9 +349,6 @@ isnow(endp, monthp, dayp, varp) } } -#if DEBUG - fprintf(stderr, "day2: day %d yday %d\n", day, tp->tm_yday); -#endif if (!(flags & F_EASTER)) { *monthp = month; *dayp = day; @@ -372,6 +362,9 @@ isnow(endp, monthp, dayp, varp) *varp = 1; } +#if DEBUG + fprintf(stderr, "day2: day %d(%d) yday %d\n", *dayp, day, tp->tm_yday); +#endif /* if today or today + offset days */ if (day >= tp->tm_yday - f_dayBefore && day <= tp->tm_yday + offset + f_dayAfter) diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 8b2a6763cce4..fbc5d4658f9f 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -129,9 +129,23 @@ cal() continue; if (p > buf && p[-1] == '*') var = 1; - if (printing) - (void)fprintf(fp, "%.2d/%.2d%c%s\n", month, - day, var ? '*' : ' ', p); + if (printing) { + struct tm tm; + char dbuf[30]; + + tm.tm_sec = 0; /* unused */ + tm.tm_min = 0; /* unused */ + tm.tm_hour = 0; /* unused */ + tm.tm_wday = 0; /* unused */ + tm.tm_mon = month - 1; + tm.tm_mday = day; + tm.tm_year = tp->tm_year; /* unused */ + (void)strftime(dbuf, sizeof(dbuf), "%c", &tm); + dbuf[10] = '\0'; + (void)fprintf(fp, "%s%c%s\n", + dbuf + 4/* skip weekdays */, + var ? '*' : ' ', p); + } } else if (printing) fprintf(fp, "%s\n", buf); diff --git a/usr.bin/calendar/paskha.c b/usr.bin/calendar/paskha.c index 28eb8c0f474a..42c20587aa6a 100644 --- a/usr.bin/calendar/paskha.c +++ b/usr.bin/calendar/paskha.c @@ -50,7 +50,7 @@ int R; /*year*/ c = R % 7; d = (19*a + x) % 30; e = (2*b + 4*c + 6*d + y) % 7; - return ((cumdays[2/*feb*/] + 22/*mar*/) + (d + e)); + return (((cumdays[3] + 1) + 22) + (d + e)); } /* return year day for Orthodox Easter depending days */