LegacyDate::getSortDate - jcobban/Genealogy GitHub Wiki

$date->getSortDate()

Up: class LegacyDate

This returns a numeric sort key that is used whenever the user requests that events or facts be ordered by date. For dates between 1 Jan 1 and 13 Oct 1582 this is yyyymmdd where yyyy, mm, and dd are the Julian year, month, and date. For dates after 13 Oct 1582 this is yyyymmdd where yyyy, mm, and dd are the Gregorian year, month, and date. For dates before the Common Era (BCE) it returns -y * 10000 + mmdd where yyyy, mm, and dd are the proleptic Julian year, month, and date. Note that this is different from the implementation in Legacy Family Tree which stores -ymmdd, because the Legacy implementation would sort backward for BCE dates. Consider the most famous BCE date, the Ides of March 44 BCE. -440315 is less than -440101 so the Ides of March would sort before the Kalends of January of that year. −439685 is greater than −439899. You can extract the year for any date by floor(sortdate/10000). The mmdd portion is always sortdate - floor(sortdate/10000). Remember that year numbers are actually ordinal numbers so there is no year zero in the Julian Calendar. The 1st year before the Common Era (BCE) was immediately followed by the 1st year of the Common Era (CE). 2021 is the 2021st year of the Common Era. In any event to the Romans, who were the only people using the calendar at the time, the year 756 AUC, our 1 BCE, was followed by the year 757 AUC, our 1 CE. Actually most people back then knew those two years as the year of the consuls Cossus Cornelius Lentulus and L. Calpurnius Piso, and the year of the consuls C. Julius Caesar and L. Aemilius Paullus. In the eastern Mediterranean the 311th year of the Seleucid era was followed by the 312th year of the Seleucid era.

Next: $date->getJulianDate()