summaryrefslogtreecommitdiffstats
path: root/lib/libcalendar
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
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')
-rw-r--r--lib/libcalendar/Makefile4
-rw-r--r--lib/libcalendar/calendar.327
-rw-r--r--lib/libcalendar/calendar.h5
-rw-r--r--lib/libcalendar/easter.c44
4 files changed, 55 insertions, 25 deletions
diff --git a/lib/libcalendar/Makefile b/lib/libcalendar/Makefile
index fe41148..5e2a345 100644
--- a/lib/libcalendar/Makefile
+++ b/lib/libcalendar/Makefile
@@ -1,4 +1,4 @@
-# $Id$
+# $Id: Makefile,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
LIB= calendar
@@ -6,7 +6,7 @@ SRCS= calendar.c easter.c
MAN3= calendar.3
-MLINKS= calendar.3 easterg.3 calendar.3 easterj.3 \
+MLINKS= calendar.3 easterg.3 calendar.3 easterog.3 calendar.3 easteroj.3 \
calendar.3 gdate.3 calendar.3 jdate.3 \
calendar.3 ndaysg.3 calendar.3 ndaysj.3 \
calendar.3 week.3 calendar.3 weekday.3
diff --git a/lib/libcalendar/calendar.3 b/lib/libcalendar/calendar.3
index 4f51a02..0ac6544 100644
--- a/lib/libcalendar/calendar.3
+++ b/lib/libcalendar/calendar.3
@@ -22,14 +22,15 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: calendar.3,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
.\"
.Dd November 29, 1997
.Dt CALENDAR 3
.Os
.Sh NAME
.Nm easterg ,
-.Nm easterj ,
+.Nm easterog ,
+.Nm easteroj ,
.Nm gdate ,
.Nm jdate ,
.Nm ndaysg ,
@@ -42,7 +43,9 @@
.Ft date *
.Fn easterg "int year" "date *dt"
.Ft date *
-.Fn easterj "int year" "date *dt"
+.Fn easterog "int year" "date *dt"
+.Ft date *
+.Fn easteroj "int year" "date *dt"
.Ft date *
.Fn gdate "int nd" "date *dt"
.Ft date *
@@ -64,18 +67,28 @@ Programs should be linked with
.Fl lcalendar .
The functions
-.Fn easterg
+.Fn easterg ,
+.Fn easterog
and
-.Fn easterj
+.Fn easteroj
store the date of Easter Sunday into the structure pointed at by
.Fa dt
and return a pointer to this structure.
The function
.Fn easterg
assumes Gregorian Calendar (adopted by most western churches after 1582) and
-.Fn easterj
-assumes Julian Calendar (Western churches before 1582 and Greek Church
+the functions
+.Fn easterog
+and
+.Fn easteroj
+compute the date of Easter Sunday according to the orthodox rules
+(Western churches before 1582, Greek and Russian Orthodox Church
until today).
+The result returned by
+.Fn easterog
+is the date in Gregorian Calendar, whereas
+.Fn easteroj
+returns the date in Julian Calendar.
The functions
.Fn gdate ,
diff --git a/lib/libcalendar/calendar.h b/lib/libcalendar/calendar.h
index 6c8d8f9..8be8d49 100644
--- a/lib/libcalendar/calendar.h
+++ b/lib/libcalendar/calendar.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: calendar.h,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
*/
typedef struct date {
int y; /* year */
@@ -32,7 +32,8 @@ typedef struct date {
} date;
date *easterg(int _year, date *_dt);
-date *easterj(int _year, date *_dt);
+date *easterog(int _year, date *_dt);
+date *easteroj(int _year, date *_dt);
date *gdate(int _nd, date *_dt);
date *jdate(int _nd, date *_dt);
int ndaysg(date *_dt);
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