php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
sdncal.h
Go to the documentation of this file.
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 * zend_long 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#include "php.h"
69
70/* Gregorian calendar conversions. */
71void SdnToGregorian(zend_long sdn, int *pYear, int *pMonth, int *pDay);
72zend_long GregorianToSdn(int year, int month, int day);
73extern const char * const MonthNameShort[13];
74extern const char * const MonthNameLong[13];
75
76/* Julian calendar conversions. */
77void SdnToJulian(zend_long sdn, int *pYear, int *pMonth, int *pDay);
78zend_long JulianToSdn(int year, int month, int day);
79
80/* Jewish calendar conversions. */
81void SdnToJewish(zend_long sdn, int *pYear, int *pMonth, int *pDay);
82zend_long JewishToSdn(int year, int month, int day);
83extern const char * const JewishMonthName[14];
84extern const char * const JewishMonthNameLeap[14];
85extern const char * const JewishMonthHebName[14];
86extern const char * const JewishMonthHebNameLeap[14];
87extern const int monthsPerYear[19];
88
89/* French republic calendar conversions. */
90void SdnToFrench(zend_long sdn, int *pYear, int *pMonth, int *pDay);
91zend_long FrenchToSdn(int inputYear, int inputMonth, int inputDay);
92extern const char * const FrenchMonthName[14];
93
94/* Islamic calendar conversions. */
95/* Not implemented yet. */
96
97/* Day of week conversion. 0=Sunday, 6=Saturday */
98int DayOfWeek(zend_long sdn);
99extern const char * const DayNameShort[7];
100extern const char * const DayNameLong[7];
101
102#endif /* SDNCAL_H */
const char *const DayNameLong[7]
Definition dow.c:50
const char *const DayNameShort[7]
Definition dow.c:39
const char *const FrenchMonthName[14]
Definition french.c:134
const char *const MonthNameShort[13]
Definition gregor.c:247
const char *const MonthNameLong[13]
Definition gregor.c:264
const int monthsPerYear[19]
Definition jewish.c:286
const char *const JewishMonthNameLeap[14]
Definition jewish.c:298
const char *const JewishMonthHebName[14]
Definition jewish.c:355
const char *const JewishMonthHebNameLeap[14]
Definition jewish.c:336
const char *const JewishMonthName[14]
Definition jewish.c:317
zend_long JulianToSdn(int year, int month, int day)
Definition julian.c:215
int DayOfWeek(zend_long sdn)
Definition dow.c:33
void SdnToGregorian(zend_long sdn, int *pYear, int *pMonth, int *pDay)
Definition gregor.c:137
zend_long FrenchToSdn(int inputYear, int inputMonth, int inputDay)
Definition french.c:117
void SdnToJulian(zend_long sdn, int *pYear, int *pMonth, int *pDay)
Definition julian.c:155
zend_long JewishToSdn(int year, int month, int day)
Definition jewish.c:698
void SdnToJewish(zend_long sdn, int *pYear, int *pMonth, int *pDay)
Definition jewish.c:559
zend_long GregorianToSdn(int year, int month, int day)
Definition gregor.c:202
void SdnToFrench(zend_long sdn, int *pYear, int *pMonth, int *pDay)
Definition french.c:95
int32_t zend_long
Definition zend_long.h:42