Calendar Functions
The calendar functions are only available if you have compiled the calendar extension in dl/calendar. Read dl/README for instructions on using it.
The Calendar extension in PHP presents a series of functions to simplify converting between different calendar formats. The intermediary or standard it is based on is the Julian Day Count. The Julian Day Count is a count of days starting way earlier than any date most people would need to track (somewhere around 4000bc). To convert between calendar systems, you must first convert to Julian Day Count, then to the calendar system of your choice. Julian Day Count is very different from the Julian Calendar! For more information on calendar systems visit http://genealogy.org/~scottlee/cal-overview.html. Excerpts from this page are included in these instructions, and are in quotes
Calendar Functions
JDToGregorian
Name
JDToGregorian — Converts Julian Day Count to Gregorian date
Description
string jdtogregorian(int julianday);
Converts Julian Day Count to a string containing the Gregorian date in the format of "month/day/year"
GregorianToJD
Name
GregorianToJD — Converts a Gregorian date to Julian Day Count
Description
int gregoriantojd(int month, int day, int year);
Valid Range for Gregorian Calendar 4714 B.C. to 9999 A.D.
Although this software can handle dates all the way back to 4714 B.C., such use may not be meaningful. The Gregorian calendar was not instituted until October 15, 1582 (or October 5, 1582 in the Julian calendar). Some countries did not accept it until much later. For example, Britain converted in 1752, The USSR in 1918 and Greece in 1923. Most European countries used the Julian calendar prior to the Gregorian.
Example 1. Calendar functions
<?php
$jd = GregorianToJD(10,11,1970); echo("$jd\n");
$gregorian = JDToGregorian($jd); echo("$gregorian\n");
?>
JDToJulian
Name
JDToJulian — Converts a Julian Calendar date to Julian Day Count
Description
string jdtojulian(int julianday);
Converts Julian Day Count to a string containing the Julian Calendar Date in the format of "month/day/year".
JulianToJD
Name
JulianToJD — Converts a Julian Calendar date to Julian Day Count
Description
int juliantojd(int month, int day, int year);
Valid Range for Julian Calendar 4713 B.C. to 9999 A.D.
Although this software can handle dates all the way back to 4713 B.C., such use may not be meaningful. The calendar was created in 46 B.C., but the details did not stabilize until at least 8 A.D., and perhaps as late at the 4th century. Also, the beginning of a year varied from one culture to another - not all accepted January as the first month.
JDToJewish
Name
JDToJewish — Converts a Julian Day Count to the Jewish Calendar
Description
string jdtojewish(int julianday);
Converts a Julian Day Count the the Jewish Calendar.
JewishToJD
Name
JewishToJD — Converts a date in the Jewish Calendar to Julian Day Count
Description
int jewishtojd(int month, int day, int year);
Valid Range Although this software can handle dates all the way back to the year 1 (3761 B.C.), such use may not be meaningful.
The Jewish calendar has been in use for several thousand years, but in the early days there was no formula to determine the start of a month. A new month was started when the new moon was first observed.
JDToFrench
Name
JDToFrench — Converts a Julian Day Count to the French Republican Calendar
Description
string jdtofrench(int month, int day, int year);
Converts a Julian Day Count to the French Republican Calendar.
FrenchToJD
Name
FrenchToJD — Converts a date from the French Republican Calendar to a Julian Day Count
Description
int frenchtojd(int month, int day, int year);
Converts a date from the French Republican Calendar to a Julian Day Count
These routines only convert dates in years 1 through 14 (Gregorian dates 22 September 1792 through 22 September 1806). This more than covers the period when the calendar was in use.
JDMonthName
Name
JDMonthName — Returns a month name
Description
string jdmonthname(int julianday, int mode);
Returns a string containing a month name. mode tells this function which calendar to convert the Julian Day Count to, and what type of month names are to be returned.
Table 1. Calendar modes
Mode |
Meaning |
---|---|
0 | Gregorian - apreviated |
1 |
Gregorian |
2 |
Julian - apreviated |
3 | Julian |
4 | Jewish |
5 | French Republican |
JDDayOfWeek
Name
JDDayOfWeek — Returns the day of the week
Description
mixed jddayofweek(int julianday, int mode);
Returns the day of the week. Can return a string or an int depending on the mode.
Table 1. Calendar week modes
Mode |
Meaning |
---|---|
0 | returns the day number as an int (0=sunday, 1=monday, etc) |
1 | returns string containing the day of week (english-gregorian) |
2 | returns a string containing the abreviated day of week (english-gregorian) |