jdtofrench()
Introduction
The French Revolutionary Calendar, also known as the Republican Calendar, was created during the French Revolution and was used in France from 1793 to 1805. It was designed to replace the Gregorian calendar and was intended to be more rational and scientific. The calendar was based on the idea of decimal time and consisted of 12 months of 30 days each, with an additional 5 or 6 days added at the end of the year to make up for the extra days.
Julian Day Count, on the other hand, is a system of counting days used in astronomy. It is defined as the number of days that have elapsed since noon on January 1, 4713 BCE (Julian calendar). PHP includes a built-in jdtofrench() function in the Calendar extension for converting Julian Day Count to the French Revolutionary Calendar, which automatically handles the calendar's leap year rules.
Conversion Formula
To convert Julian Day Count to French Revolutionary Calendar Date, we use the following algorithm:
J = JDC - 2375839
N = J mod 365
if N < 360 then
Q = floor(N / 30) + 1
R = (N mod 30) + 1
else
Q = 13
R = N - 359
end ifWhere:
- J is the number of days elapsed since the start of the French Revolutionary Calendar (September 22, 1792)
- N is the day number in the current year (0-364)
- Q is the month number (1-12 for the 12 months, 13 for the complementary days)
- R is the day number in the month (1-30) or the complementary day (1-5/6)
Explanation of Formula
The formula for converting Julian Day Count to French Revolutionary Calendar Date is straightforward once broken down. Let's look at each step.
Step 1: Calculate J and N
First, calculate J by subtracting 2375839 (the Julian Day Count of September 22, 1792, the calendar's epoch) from the target Julian Day Count. Then, find N, the day number within the current 365-day cycle:
J = JDC - 2375839
N = J mod 365Step 2: Calculate Q and R
The French Revolutionary calendar divides the year into 12 months of exactly 30 days, followed by 5 or 6 complementary days. We determine the month (Q) and day (R) using these rules:
if N < 360 then
Q = floor(N / 30) + 1
R = (N mod 30) + 1
else
Q = 13
R = N - 359
end ifIf N is less than 360, the date falls within one of the 12 months. We divide N by 30 to find the month index and add 1. The remainder gives the day index, also adjusted by adding 1. If N is 360 or greater, the date falls in the complementary days period (Sans-culottides), which is assigned month number 13.
Example
Let's convert the Julian Day Count 2376000 to a French Revolutionary Calendar Date.
First, calculate J and N:
J = 2376000 - 2375839 = 161
N = 161 mod 365 = 161Next, calculate Q and R:
N < 360, so:
Q = floor(161 / 30) + 1 = 5 + 1 = 6
R = (161 mod 30) + 1 = 11 + 1 = 12Month 6 corresponds to Brumaire. Therefore, the Julian Day Count 2376000 corresponds to 12 Brumaire, Year 1 (October 12, 1792).
PHP Implementation
PHP provides a native jdtofrench() function in the Calendar extension, which handles the conversion and leap year logic automatically:
// Requires the Calendar extension
echo jdtofrench(2376000); // Outputs: 12 Brumaire, Year 1For dates before the calendar's epoch (September 22, 1792), you should validate the input to avoid unexpected results:
$jdc = 2376000;
if ($jdc >= 2375839) {
echo jdtofrench($jdc);
} else {
echo "Date is before the French Revolutionary Calendar epoch.";
}Conclusion
In conclusion, PHP provides a built-in jdtofrench() function in the Calendar extension for converting Julian Day Counts to French Revolutionary Calendar dates. By using this native function, you can accurately translate historical dates while automatically accounting for the calendar's leap year rules and complementary days.
Practice
What does the jdtofrench() function in PHP do?