Path: csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Calculate date of Easter or Good Friday
Date: Sun, 03 Mar 2024 10:03:42 -0800
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <868r2ztcox.fsf@linuxsc.com>
References:
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="8e6876f3e46194a45503e9d93596105d"; logging-data="2754882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fQQ4W4RPg8nrfYJdsME7DVHunu1DIgNw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:fGEbBgEWAK46jMzCkrS1u9nHMXA= sha1:gk2yGYa+YBuOs2GR5VJcOh4BSl8=
Xref: csiph.com comp.lang.c:383266
vallor writes:
>> [...]
>
> ncal(1) has the -e and -o options for both Easters. I went looking
> for the source of the Easter-computation code, found one copy here:
>
> https://github.com/lattera/freebsd/blob/master/lib/libcalendar/easter.c
>
> On Ubuntu with source repositories enabled, one can get the BSD
> ncal (with its bundled libcalendar) with
>
> $ apt-get source ncal
>
> I really wish the function easterg() was commented better.
>
> /* Compute Easter Sunday in Gregorian Calendar */
> date *
> easterg(int y, date *dt)
> {
> int c, i, j, k, l, n;
>
> n = y % 19;
> c = y / 100;
> k = (c - 17) / 25;
> i = (c - c/4 -(c-k)/3 + 19 * n + 15) % 30;
> i = i -(i/28) * (1 - (i/28) * (29/(i + 1)) * ((21 - n)/11));
> j = (y + y/4 + i + 2 - c + c/4) % 7;
> l = i - j;
> dt->m = 3 + (l + 40) / 44;
> dt->d = l + 28 - 31*(dt->m / 4);
> dt->y = y;
> return (dt);
> }
>
> The code is 27 years old. I will not pretend to understand it.
> (Yet?)
Seems like bad style to have two assignments to 'i'. Easily
fixable simply by adding another variable.