summaryrefslogtreecommitdiffstats
path: root/lib/libcalendar/easter.c
diff options
context:
space:
mode:
authorhelbig <helbig@FreeBSD.org>1997-12-07 19:04:14 +0000
committerhelbig <helbig@FreeBSD.org>1997-12-07 19:04:14 +0000
commit0a7ec97b1d75f76dd7f786aa7917df1cfaf8240e (patch)
treecc9858f6235d45fb7be5476b0396bd1eb8289bd2 /lib/libcalendar/easter.c
parentdf8959040c85f44e820fb5edb8f8f65fe23c8ed0 (diff)
downloadFreeBSD-src-0a7ec97b1d75f76dd7f786aa7917df1cfaf8240e.zip
FreeBSD-src-0a7ec97b1d75f76dd7f786aa7917df1cfaf8240e.tar.gz
Added easterog() and easteroj() which compute orthodox easter for
Gregorian and Julian Calendar. Suggested by: Andrey
Diffstat (limited to 'lib/libcalendar/easter.c')
-rw-r--r--lib/libcalendar/easter.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/lib/libcalendar/easter.c b/lib/libcalendar/easter.c
index 53021f7..fa43837 100644
--- a/lib/libcalendar/easter.c
+++ b/lib/libcalendar/easter.c
@@ -23,11 +23,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: easter.c,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
*/
#include "calendar.h"
+static int easterodn(int y);
+
/* Compute Easter Sunday in Gregorian Calendar */
date *
easterg(int y, date *dt)
@@ -47,11 +49,26 @@ easterg(int y, date *dt)
return (dt);
}
-/* Compute Easter Sunday in Julian Calendar */
+/* Compute the Gregorian date of Easter Sunday in Julian Calendar */
+date *
+easterog(int y, date *dt)
+{
+
+ return (gdate(easterodn(y), dt));
+}
+
+/* Compute the Julian date of Easter Sunday in Julian Calendar */
date *
-easterj(int y, date * dt)
+easteroj(int y, date * dt)
{
+ return (jdate(easterodn(y), dt));
+}
+
+/* Compute the day number of Easter Sunday in Julian Calendar */
+static int
+easterodn(int y)
+{
/*
* Table for the easter limits in one metonic (19-year) cycle. 21
* to 31 is in March, 1 through 18 in April. Easter is the first
@@ -62,21 +79,20 @@ easterj(int y, date * dt)
/* Offset from a weekday to next sunday */
int ns[] = {6, 5, 4, 3, 2, 1, 7};
+ date dt;
int dn;
- /* Assign the easter limit of y to *dt */
- dt->d = mc[y % 19];
+ /* Assign the easter limit of y to dt */
+ dt.d = mc[y % 19];
- if (dt->d < 21)
- dt->m = 4;
+ if (dt.d < 21)
+ dt.m = 4;
else
- dt->m = 3;
-
- dt->y = y;
+ dt.m = 3;
- /* Compute the next sunday after the easter limit */
- dn = ndaysj(dt);
- dn += ns[weekday(dn)];
+ dt.y = y;
- return (jdate(dn, dt));
+ /* Return the next sunday after the easter limit */
+ dn = ndaysj(&dt);
+ return (dn + ns[weekday(dn)]);
}
OpenPOWER on IntegriCloud