Chapter 7 · pp. 60–62
Calendar date → Julian Day
Civil calendars are awkward coordinates for computation: months have different lengths, leap years interrupt the rhythm, and historical calendar changes add discontinuities. The Julian Day (JD) replaces them with one continuous count of days and fractions of a day.
Core relation
JD = ⌊365.25(Y + 4716)⌋ + ⌊30.6001(M + 1)⌋ + D + B − 1524.5
Inputs
Julian Day2436116.310000
Modified JD36115.810000
Decimal day4.81000000
Implementation
The same floor-based recipe in multiple languages.
function calendarToJD(year, month, day, calendar = "gregorian") {
let y = year;
let m = month;
if (m <= 2) {
y -= 1;
m += 12;
}
let correction = 0;
if (calendar === "gregorian") {
const century = Math.floor(y / 100);
correction = 2 - century + Math.floor(century / 4);
}
return Math.floor(365.25 * (y + 4716))
+ Math.floor(30.6001 * (m + 1))
+ day + correction - 1524.5;
}Reference check
1957 Oct 4.81 → JD 2436116.31