Added easterog() and easteroj() which compute orthodox easter for
Gregorian and Julian Calendar. Suggested by: Andrey
This commit is contained in:
parent
ed1b05436a
commit
4000696ce7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31611
@ -1,4 +1,4 @@
|
|||||||
# $Id$
|
# $Id: Makefile,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
|
||||||
|
|
||||||
LIB= calendar
|
LIB= calendar
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ SRCS= calendar.c easter.c
|
|||||||
|
|
||||||
MAN3= calendar.3
|
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 gdate.3 calendar.3 jdate.3 \
|
||||||
calendar.3 ndaysg.3 calendar.3 ndaysj.3 \
|
calendar.3 ndaysg.3 calendar.3 ndaysj.3 \
|
||||||
calendar.3 week.3 calendar.3 weekday.3
|
calendar.3 week.3 calendar.3 weekday.3
|
||||||
|
@ -22,14 +22,15 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" $Id$
|
.\" $Id: calendar.3,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd November 29, 1997
|
.Dd November 29, 1997
|
||||||
.Dt CALENDAR 3
|
.Dt CALENDAR 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm easterg ,
|
.Nm easterg ,
|
||||||
.Nm easterj ,
|
.Nm easterog ,
|
||||||
|
.Nm easteroj ,
|
||||||
.Nm gdate ,
|
.Nm gdate ,
|
||||||
.Nm jdate ,
|
.Nm jdate ,
|
||||||
.Nm ndaysg ,
|
.Nm ndaysg ,
|
||||||
@ -42,7 +43,9 @@
|
|||||||
.Ft date *
|
.Ft date *
|
||||||
.Fn easterg "int year" "date *dt"
|
.Fn easterg "int year" "date *dt"
|
||||||
.Ft date *
|
.Ft date *
|
||||||
.Fn easterj "int year" "date *dt"
|
.Fn easterog "int year" "date *dt"
|
||||||
|
.Ft date *
|
||||||
|
.Fn easteroj "int year" "date *dt"
|
||||||
.Ft date *
|
.Ft date *
|
||||||
.Fn gdate "int nd" "date *dt"
|
.Fn gdate "int nd" "date *dt"
|
||||||
.Ft date *
|
.Ft date *
|
||||||
@ -64,18 +67,28 @@ Programs should be linked with
|
|||||||
.Fl lcalendar .
|
.Fl lcalendar .
|
||||||
|
|
||||||
The functions
|
The functions
|
||||||
.Fn easterg
|
.Fn easterg ,
|
||||||
|
.Fn easterog
|
||||||
and
|
and
|
||||||
.Fn easterj
|
.Fn easteroj
|
||||||
store the date of Easter Sunday into the structure pointed at by
|
store the date of Easter Sunday into the structure pointed at by
|
||||||
.Fa dt
|
.Fa dt
|
||||||
and return a pointer to this structure.
|
and return a pointer to this structure.
|
||||||
The function
|
The function
|
||||||
.Fn easterg
|
.Fn easterg
|
||||||
assumes Gregorian Calendar (adopted by most western churches after 1582) and
|
assumes Gregorian Calendar (adopted by most western churches after 1582) and
|
||||||
.Fn easterj
|
the functions
|
||||||
assumes Julian Calendar (Western churches before 1582 and Greek Church
|
.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).
|
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
|
The functions
|
||||||
.Fn gdate ,
|
.Fn gdate ,
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id: calendar.h,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
|
||||||
*/
|
*/
|
||||||
typedef struct date {
|
typedef struct date {
|
||||||
int y; /* year */
|
int y; /* year */
|
||||||
@ -32,7 +32,8 @@ typedef struct date {
|
|||||||
} date;
|
} date;
|
||||||
|
|
||||||
date *easterg(int _year, date *_dt);
|
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 *gdate(int _nd, date *_dt);
|
||||||
date *jdate(int _nd, date *_dt);
|
date *jdate(int _nd, date *_dt);
|
||||||
int ndaysg(date *_dt);
|
int ndaysg(date *_dt);
|
||||||
|
@ -23,11 +23,13 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id: easter.c,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
|
|
||||||
|
static int easterodn(int y);
|
||||||
|
|
||||||
/* Compute Easter Sunday in Gregorian Calendar */
|
/* Compute Easter Sunday in Gregorian Calendar */
|
||||||
date *
|
date *
|
||||||
easterg(int y, date *dt)
|
easterg(int y, date *dt)
|
||||||
@ -47,11 +49,26 @@ easterg(int y, date *dt)
|
|||||||
return (dt);
|
return (dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute Easter Sunday in Julian Calendar */
|
/* Compute the Gregorian date of Easter Sunday in Julian Calendar */
|
||||||
date *
|
date *
|
||||||
easterj(int y, date * dt)
|
easterog(int y, date *dt)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
return (gdate(easterodn(y), dt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute the Julian date of Easter Sunday in Julian Calendar */
|
||||||
|
date *
|
||||||
|
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
|
* 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
|
* 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 */
|
/* Offset from a weekday to next sunday */
|
||||||
int ns[] = {6, 5, 4, 3, 2, 1, 7};
|
int ns[] = {6, 5, 4, 3, 2, 1, 7};
|
||||||
|
date dt;
|
||||||
int dn;
|
int dn;
|
||||||
|
|
||||||
/* Assign the easter limit of y to *dt */
|
/* Assign the easter limit of y to dt */
|
||||||
dt->d = mc[y % 19];
|
dt.d = mc[y % 19];
|
||||||
|
|
||||||
if (dt->d < 21)
|
if (dt.d < 21)
|
||||||
dt->m = 4;
|
dt.m = 4;
|
||||||
else
|
else
|
||||||
dt->m = 3;
|
dt.m = 3;
|
||||||
|
|
||||||
dt->y = y;
|
dt.y = y;
|
||||||
|
|
||||||
/* Compute the next sunday after the easter limit */
|
/* Return the next sunday after the easter limit */
|
||||||
dn = ndaysj(dt);
|
dn = ndaysj(&dt);
|
||||||
dn += ns[weekday(dn)];
|
return (dn + ns[weekday(dn)]);
|
||||||
|
|
||||||
return (jdate(dn, dt));
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user