Julian Day - Calculation - Gregorian Calendar From Julian Day Number

Gregorian Calendar From Julian Day Number

  • Let J be the Julian day number from which we want to compute the date components.
  • From J, compute a relative Julian day number j from a Gregorian epoch starting on March 1, −4800 (i.e. March 1, 4801 BC in the proleptic Gregorian Calendar), the beginning of the Gregorian quadricentennial 32,044 days before the epoch of the Julian Period.
  • From j, compute the number g of Gregorian quadricentennial cycles elapsed (there are exactly 146,097 days per cycle) since the epoch; subtract the days for this number of cycles, it leaves dg days since the beginning of the current cycle.
  • From dg, compute the number c (from 0 to 4) of Gregorian centennial cycles (there are exactly 36,524 days per Gregorian centennial cycle) elapsed since the beginning of the current Gregorian quadricentennial cycle, number reduced to a maximum of 3 (this reduction occurs for the last day of a leap centennial year where c would be 4 if it were not reduced); subtract the number of days for this number of Gregorian centennial cycles, it leaves dc days since the beginning of a Gregorian century.
  • From dc, compute the number b (from 0 to 24) of Julian quadrennial cycles (there are exactly 1,461 days in 4 years, except for the last cycle which may be incomplete by 1 day) since the beginning of the Gregorian century; subtract the number of days for this number of Julian cycles, it leaves db days in the Gregorian century.
  • From db, compute the number a (from 0 to 4) of Roman annual cycles (there are exactly 365 days per Roman annual cycle) since the beginning of the Julian quadrennial cycle, number reduced to a maximum of 3 (this reduction occurs for the leap day, if any, where a would be 4 if it were not reduced); subtract the number of days for this number of annual cycles, it leaves da days in the Julian year (that begins on March 1).
  • Convert the four components g, c, b, a into the number y of years since the epoch, by summing their values weighted by the number of years that each component represents (respectively 400 years, 100 years, 4 years, and 1 year).
  • With da, compute the number m (from 0 to 11) of months since March (there are exactly 153 days per 5-month cycle; however, these 5-month cycles are offset by 2 months within the year, i.e. the cycles start in May, and so the year starts with an initial fixed number of days on March 1, the month can be computed from this cycle by a Euclidian division by 5); subtract the number of days for this number of months (using the formula above), it leaves d days past since the beginning of the month.
  • The Gregorian date (Y, M, D) can then be deduced by simple shifts from (y, m, d).

The calculations below (which use integer division and modulo with positive numbers only) are valid for the whole range of dates since −4800. For dates before 1582, the resulting date components are valid only in the Gregorian proleptic calendar. This is based on the Gregorian calendar but extended to cover dates before its introduction, including the pre-Christian era. For dates in that era (before year AD 1), astronomical year numbering is used. This includes a year zero, which immediately precedes AD 1. Astronomical year zero is 1 BC in the proleptic Gregorian calendar and, in general, proleptic Gregorian year (n BC) = astronomical year (Y = 1 − n). For astronomical year Y (Y < 1), the proleptic Gregorian year is (1 − Y) BC.

Let J = JD + 0.5: (note: this shifts the epoch back by one half day, to start it at 00:00UTC, instead of 12:00 UTC);
  • let j = J + 32044; (note: this shifts the epoch back to astronomical year -4800 instead of the start of the Christian era in year AD 1 of the proleptic Gregorian calendar).
  • let g = j div 146097; let dg = j mod 146097;
  • let c = (dg div 36524 + 1) × 3 div 4; let dc = dgc × 36524;
  • let b = dc div 1461; let db = dc mod 1461;
  • let a = (db div 365 + 1) × 3 div 4; let da = dba × 365;
  • let y = g × 400 + c × 100 + b × 4 + a; (note: this is the integer number of full years elapsed since March 1, 4801 BC at 00:00 UTC);
  • let m = (da × 5 + 308) div 153 − 2; (note: this is the integer number of full months elapsed since the last March 1 at 00:00 UTC);
  • let d = da − (m + 4) × 153 div 5 + 122; (note: this is the number of days elapsed since day 1 of the month at 00:00 UTC, including fractions of one day);
  • let Y = y − 4800 + (m + 2) div 12;
  • let M = (m + 2) mod 12 + 1;
  • let D = d + 1;
return astronomical Gregorian date (Y, M, D).

The operations div and mod used here are intended to have the same binary operator priority as the multipication and division, and defined as:

You can also use only integers in most of the formula above, by taking J = floor(JD + 0.5), to compute the three integers (Y, M, D).

The time of the day is then computed from the fractional day T = frac(JD + 0.5). The additive 0.5 constant can also be adjusted to take the local timezone into account, when computing an astronomical Gregorian date localized in another timezone than UTC. To convert the fractional day into actual hours, minutes, seconds, the astronomical Gregorian calendar uses a constant length of 24 hours per day (i.e. 86400 seconds exactly), ignoring leap seconds inserted or deleted at end of some specific days in the UTC Gregorian calendar. If you want to convert it to actual UTC time, you will need to compensate the UTC leap seconds by adding them to J before restarting the computation (however this adjustment requires a lookup table, because leap seconds are not predictable with a simple formula); you'll also need to finally determine which of the two possible UTC date and time is used at times where leap seconds are added (no final compensation will be needed if negative leap seconds are occurring on the rare possible days that could be shorter than 24 hours).

Read more about this topic:  Julian Day, Calculation

Famous quotes containing the words calendar, julian, day and/or number:

    To divide one’s life by years is of course to tumble into a trap set by our own arithmetic. The calendar consents to carry on its dull wall-existence by the arbitrary timetables we have drawn up in consultation with those permanent commuters, Earth and Sun. But we, unlike trees, need grow no annual rings.
    Clifton Fadiman (b. 1904)

    The rich were dull and they drank too much or they played too much backgammon. They were dull and they were repetitious. He remembered poor Julian and his romantic awe of them and how he had started a story once that began, “The very rich are different from you and me.” And how someone had said to Julian, “Yes, they have more money.”
    Ernest Hemingway (1899–1961)

    A day in thy courts is better than a thousand.
    Bible: Hebrew Psalms, 84:10.

    As Jerome expanded, its chances for the title, “the toughest little town in the West,” increased and when it was incorporated in 1899 the citizens were able to support the claim by pointing to the number of thick stone shutters on the fronts of all saloons, gambling halls, and other places of business for protection against gunfire.
    —Administration in the State of Ariz, U.S. public relief program (1935-1943)