411 REFERENCE · Wikibooks
Algorithm Implementation/Date and time/Julian date operations
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
These are various formulas for dealing with Julian day numbers.
Converting Julian calendar date to Julian day number
The algorithmL. E. Doggett, Ch. 12, "Calendars", p. 606, in Seidelmann 1992 is valid for all (possibly proleptic Julian calendar years ≥ −4712, that is, for all JDN ≥ 0. Divisions are integer divisions, fractional parts are ignored.
Finding Julian date given Julian day number and time of day
For the full Julian Date of a moment after 12:00 UT one can use the following. Divisions are real numbers.
So, for example, January 1, 2000, at 18:00:00 UT corresponds to JD = 2451545.25 and January 1, 2000, at 6:00:00 UT corresponds to JD = 2451544.75.
Finding day of week given Julian day number
Because a Julian day starts at noon while a civil day starts at midnight, the Julian day number needs to be adjusted to find the day of week: for a point in time in a given Julian day after midnight UT and before 12:00 UT, add 1 or use the JDN of the next afternoon.
The US day of the week W1 (for an afternoon or evening UT) can be determined from the Julian Day Number J with the expression:
W1 = mod(J + 1, 7)Richards 2013, pp. 592, 618.
W1 0 1 2 3 4 5 6Day of the weekSunMonTueWedThuFriSat
If the moment in time is after midnight UT (and before 12:00 UT), then one is already in the next day of the week.
The ISO day of the week W0 can be determined from the Julian Day Number J with the expression:
W0 = mod (J, 7) + 1
W0 1 2 3 4 5 6 7Day of the weekMonTueWedThuFriSatSun
Julian or Gregorian calendar from Julian day number
This is an algorithm by Edward Graham Richards to convert a Julian Day Number, J, to a date in the Gregorian calendar (proleptic, when applicable). Richards states the algorithm is valid for Julian day numbers greater than or equal to 0.Richards 2013, 617–619Richards 1998, 316 All variables are integer values, and the notation "a div b" indicates integer division, and "mod(a,b)" denotes the modulus operator.
+Algorithm parameters for Gregorian calendar variable value variable value y 4716 v 3 j 1401 u 5 m 2 s 153 n 12 w 2 r 4 B 274277 p 1461 C −38
For Julian calendar:
f = J + j
For Gregorian calendar:
f = J + j + (((4 × J + B) div 146097) × 3) div 4 + C
For Julian or Gregorian, continue:
e = r × f + v
g = mod(e, p) div r
h = u × g + w
D = (mod(h, s)) div u + 1
M = mod(h div s + m, n) + 1
Y = (e div p) - y + (n + m - M) div n
D, M, and Y are the numbers of the day, month, and year respectively for the afternoon at the beginning of the given Julian day.
Julian Period from indiction, Metonic and solar cycles
Let Y be the year BC or AD and i, m, and s respectively its positions in the indiction, Metonic and solar cycles. Divide 6916i + 4200m + 4845s by 7980 and call the remainder r.
If r>4713, Y = (r − 4713) and is a year AD.
If r<4714, Y = (4714 − r) and is a year BC.
Example
i = 8, m = 2, s = 8. What is the year?
(6916 × 8) = 55328; (4200 × 2) = 8400: (4845 × 8) = 38760. 55328 + 8400 + 38760 = 102488.
102488/7980 = 12 remainder 6728.
Y = (6728 − 4713) = AD 2015.Heath 1760, p. 160.
Notes