1 /* This file is taken from http://www.genealogy.org/~scottlee/
2 Only this initial comment has been added. The next comment
3 gives the original copyright notice.
6 #ifndef _INCLUDED_SDNCAL_H
7 #define _INCLUDED_SDNCAL_H
9 /* $selId: sdncal.h,v 2.0 1995/10/24 01:13:06 lees Exp $
10 * Copyright 1993-1995, Scott E. Lee, all rights reserved.
11 * Permission granted to use, copy, modify, distribute and sell so long as
12 * the above copyright and this permission statement are retained in all
13 * copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
16 /**************************************************************************
18 * This package defines a set of routines that convert calendar dates to
19 * and from a serial day number (SDN). The SDN is a serial numbering of
20 * days where SDN 1 is November 25, 4714 BC in the Gregorian calendar and
21 * SDN 2447893 is January 1, 1990. This system of day numbering is
22 * sometimes referred to as Julian days, but to avoid confusion with the
23 * Julian calendar, it is referred to as serial day numbers here. The term
24 * Julian days is also used to mean the number of days since the beginning
25 * of the current year.
27 * The SDN can be used as an intermediate step in converting from one
28 * calendar system to another (such as Gregorian to Jewish). It can also
29 * be used for date computations such as easily comparing two dates,
30 * determining the day of the week, finding the date of yesterday or
31 * calculating the number of days between two dates.
33 * When using this software on 16 bit systems, be careful to store SDNs in
34 * a long int, because it will not fit in the 16 bits that some systems
37 * For each calendar, there are two routines provided. One converts dates
38 * in that calendar to SDN and the other converts SDN to calendar dates.
39 * The routines are named SdnTo<CALENDAR>() and <CALENDAR>ToSdn(), where
40 * <CALENDAR> is the name of the calendar system.
42 * SDN values less than one are not supported. If a conversion routine
43 * returns an SDN of zero, this means that the date given is either invalid
44 * or is outside the supported range for that calendar.
46 * At least some validity checks are performed on input dates. For
47 * example, a negative month number will result in the return of zero for
48 * the SDN. A returned SDN greater than one does not necessarily mean that
49 * the input date was valid. To determine if the date is valid, convert it
50 * to SDN, and if the SDN is greater than zero, convert it back to a date
51 * and compare to the original. For example:
57 * sdn = GregorianToSdn(y1, m1, d1);
59 * SdnToGregorian(sdn, &y2, &m2, &d2);
60 * if (y1 == y2 && m1 == m2 && d1 == d2) {
61 * ... date is valid ...
65 **************************************************************************/
67 /* Gregorian calendar conversions. */
68 void SdnToGregorian(long int sdn, int *pYear, int *pMonth, int *pDay);
69 long int GregorianToSdn(int year, int month, int day);
70 extern char *MonthNameShort[13];
71 extern char *MonthNameLong[13];
73 /* Julian calendar conversions. */
74 void SdnToJulian(long int sdn, int *pYear, int *pMonth, int *pDay);
75 long int JulianToSdn(int year, int month, int day);
77 /* Jewish calendar conversions. */
78 void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay);
79 long int JewishToSdn(int year, int month, int day);
80 extern char *JewishMonthName[14];
82 /* French republic calendar conversions. */
83 void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay);
84 long int FrenchToSdn(int inputYear, int inputMonth, int inputDay);
85 extern char *FrenchMonthName[14];
87 /* Islamic calendar conversions. */
88 /* Not implemented yet. */
90 /* Day of week conversion. 0=Sunday, 6=Saturday */
91 int DayOfWeek(long int sdn);
92 extern char *DayNameShort[7];
93 extern char *DayNameLong[7];
95 #endif /* _INCLUDED_SDNCAL_H */