summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libcalendar/calendar.362
-rw-r--r--lib/libcalendar/calendar.c4
-rw-r--r--lib/libcalendar/calendar.h24
-rw-r--r--lib/libcalendar/easter.c4
4 files changed, 51 insertions, 43 deletions
diff --git a/lib/libcalendar/calendar.3 b/lib/libcalendar/calendar.3
index 0ac6544..bbf5ede 100644
--- a/lib/libcalendar/calendar.3
+++ b/lib/libcalendar/calendar.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: calendar.3,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
+.\" $Id: calendar.3,v 1.2 1997/12/07 19:04:08 helbig Exp $
.\"
.Dd November 29, 1997
.Dt CALENDAR 3
@@ -40,20 +40,20 @@
.Nd Calendar arithmetic for the Christian era.
.Sh SYNOPSIS
.Fd #include <calendar.h>
-.Ft date *
-.Fn easterg "int year" "date *dt"
-.Ft date *
-.Fn easterog "int year" "date *dt"
-.Ft date *
-.Fn easteroj "int year" "date *dt"
-.Ft date *
-.Fn gdate "int nd" "date *dt"
-.Ft date *
-.Fn jdate "int nd" "date *dt"
+.Ft struct date *
+.Fn easterg "int year" "struct date *dt"
+.Ft struct date *
+.Fn easterog "int year" "struct date *dt"
+.Ft struct date *
+.Fn easteroj "int year" "struct date *dt"
+.Ft struct date *
+.Fn gdate "int nd" "struct date *dt"
+.Ft struct date *
+.Fn jdate "int nd" "struct date *dt"
.Ft int
-.Fn ndaysg "date *dt"
+.Fn ndaysg "struct date *dt"
.Ft int
-.Fn ndaysj "date *dt"
+.Fn ndaysj "struct date *dt"
.Ft int
.Fn week "int nd" "int *year"
.Ft int
@@ -62,10 +62,10 @@
These functions provide calendar arithmetic for a large range of years,
starting at March 1st, year zero (i. e. 1 B.C.) and ending way beyond
year 100000.
-
+.Pp
Programs should be linked with
.Fl lcalendar .
-
+.Pp
The functions
.Fn easterg ,
.Fn easterog
@@ -89,7 +89,7 @@ The result returned by
is the date in Gregorian Calendar, whereas
.Fn easteroj
returns the date in Julian Calendar.
-
+.Pp
The functions
.Fn gdate ,
.Fn jdate ,
@@ -101,7 +101,7 @@ of a date and the "number of days" representation, which is better suited
for calculations. The days are numbered from March 1st year 1 B.C., starting
with zero, so the number of a day gives the number of days since March 1st,
year 1 B.C. The conversions work for nonnegative day numbers only.
-
+.Pp
The
.Fn gdate
and
@@ -112,7 +112,7 @@ store the date corresponding to the day number
into the structure pointed at by
.Fa dt
and return a pointer to this structure.
-
+.Pp
The
.Fn ndaysg
and
@@ -120,19 +120,19 @@ and
functions
return the day number of the date pointed at by
.Fa dt .
-
+.Pp
The
.Fn gdate
and
.Fn ndaysg
functions
-assume Gregorian Calendar after October 4th 1582 and Julian Calendar before,
+assume Gregorian Calendar after October 4, 1582 and Julian Calendar before,
whereas
.Fn jdate
and
.Fn ndaysj
assume Julian Calendar throughout.
-
+.Pp
The two calendars differ by the definition of the leap year. The
Julian Calendar says every year that is a multiple of four is a
leap year. The Gregorian Calendar excludes years that are multiples of
@@ -140,9 +140,13 @@ leap year. The Gregorian Calendar excludes years that are multiples of
This means the years 1700, 1800, 1900, 2100 are not leap years
and the year 2000 is
a leap year.
-The new rules were inaugurated on October 4th 1582 by deleting ten
-days following this date.
-
+The new rules were inaugurated on October 4, 1582 by deleting ten
+days following this date. Most catholic countries adopted the new
+calendar by the end of the 16th century, whereas others stayed with
+the Julian Calendar until the 20th century. The United Kingdom and
+their colonies switched on September 2, 1752. They already had to
+delete 11 days.
+.Pp
The function
.Fn week
returns the number of the week which contains the day numbered
@@ -154,15 +158,15 @@ The weeks are numbered per year starting with week 1, which is the
first week in a year that includes more than three days of the year.
Weeks start on Monday.
This function is defined for Gregorian Calendar only.
-
+.Pp
The function
.Fn weekday
returns the weekday (Mo = 0 .. Su = 6) of the day numbered
.Fa nd .
-
-The type
+.Pp
+The structure
.Fa date
-is a structure defined in
+is defined in
.Aq Pa calendar.h .
It contains these fields:
.Bd -literal -offset indent
@@ -170,7 +174,7 @@ int y; /\(** year (0000 - ????) \(**/
int m; /\(** month (1 - 12) \(**/
int d; /\(** day of month (1 - 31) \(**/
.Ed
-
+.Pp
The year zero is written as "1 B.C." by historians and "0" by astronomers
and in this library.
.Sh SEE ALSO
diff --git a/lib/libcalendar/calendar.c b/lib/libcalendar/calendar.c
index 41e79b2..ae36a4c 100644
--- a/lib/libcalendar/calendar.c
+++ b/lib/libcalendar/calendar.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: calendar.c,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
*/
#include "calendar.h"
@@ -46,6 +46,8 @@ static int const month1[] =
static int const month1s[]=
{0, 31, 61, 92, 122, 153, 184, 214, 235, 265, 296, 327};
+typedef struct date date;
+
/* The last day of Julian calendar, in internal and ndays representation */
static int nswitch; /* The last day of Julian calendar */
static date jiswitch = {1582, 7, 3};
diff --git a/lib/libcalendar/calendar.h b/lib/libcalendar/calendar.h
index 8be8d49..2e432ed 100644
--- a/lib/libcalendar/calendar.h
+++ b/lib/libcalendar/calendar.h
@@ -23,20 +23,20 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: calendar.h,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
+ * $Id: calendar.h,v 1.2 1997/12/07 19:04:11 helbig Exp $
*/
-typedef struct date {
+struct date {
int y; /* year */
int m; /* month */
int d; /* day */
-} date;
+};
-date *easterg(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);
-int ndaysj(date *_dt);
-int week(int _nd, int *_year);
-int weekday(int _nd);
+struct date *easterg(int _year, struct date *_dt);
+struct date *easterog(int _year, struct date *_dt);
+struct date *easteroj(int _year, struct date *_dt);
+struct date *gdate(int _nd, struct date *_dt);
+struct date *jdate(int _nd, struct date *_dt);
+int ndaysg(struct date *_dt);
+int ndaysj(struct date *_dt);
+int week(int _nd, int *_year);
+int weekday(int _nd);
diff --git a/lib/libcalendar/easter.c b/lib/libcalendar/easter.c
index fa43837..573f06d 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: easter.c,v 1.1.1.1 1997/12/04 10:41:49 helbig Exp $
+ * $Id: easter.c,v 1.2 1997/12/07 19:04:14 helbig Exp $
*/
#include "calendar.h"
+typedef struct date date;
+
static int easterodn(int y);
/* Compute Easter Sunday in Gregorian Calendar */
OpenPOWER on IntegriCloud