root/ext/calendar/sdncal.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


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

/* [<][>][^][v][top][bottom][index][help] */