jdn_civil

Description

jdn_civil converts a provided  Julian day number into a Civil date. It works for both the Gregorian calendar and the Julian calendar (see also civil_jdn)

Notes

  1. This routine works for both the Gregorian calendar and the Julian calendar.
  2. The year zero never existed. the year 1 BC was immediately followed by the year 1 AD. When this function retruns a non-positive year, you should be ware that the value 0 for year, means 1 BC, -1 means 2 BC et cetera.

Gory details

The formula used to calculate the civil date depends on the julian day number. A conditional expression tests whether the date is before or after Julian day number 2299160, which is when the Gregorian calendar was implemented.

The Gregorian calendar was proposed by Aloysius Lilius, a physician from Naples, to correct for errors in the older Julian Calendar. It was decreed by Pope Gregory XIII in a papal bull on 24 February 1582. The papal bull decreed that 10 days should be dropped from October 1582 so that 15 October should follow immediately after 4 October, and from then on the reformed calendar should be used.

This was observed in Italy, Poland, Portugal, and Spain. Other Catholic countries followed shortly after, but Protestant countries were reluctant to change, and the Greek orthodox countries didn't change until the start of the 1900s.

The algorithm presented here, uses the Julian day number 2299160 as the starting point for the Gregorian Calendar. It should not be hard to modify the code, to make it use the the date for change in your country.

Code section

Sub jdn_civil(ByVal jdn As Long, _
              ByRef iyear As Integer, _
              ByRef imonth As Integer, _
              ByRef iday As Integer)

    Dim l As Long
    Dim k As Long
    Dim n As Long
    Dim i As Long
    Dim j As Long

    If (jdn > 2299160) Then
        l = jdn + 68569
        n = ((4 * l) \ 146097)
        l = l - ((146097 * n + 3) \ 4)
        i = ((4000 * (l + 1)) \ 1461001)
        l = l - ((1461 * i) \ 4) + 31
        j = ((80 * l) \ 2447)
        iday = l - ((2447 * j) \ 80)
        l = (j \ 11)
        imonth = j + 2 - 12 * l
        iyear = 100 * (n - 49) + i + l
    Else
        Call jdn_julian(jdn, iyear, imonth, iday)
    End If

End Sub

See also

Notes, Operators, civil_jdn, jdn_julian

Last update

Julian Day Number: 2452096
Civil (Gregorian) date: 5 July 2001
Julian date: 22 June 2001
Hebrew date: 14 Tammuz 5761
Islamic date: 13 Rabi' II 1422

Back to Calendar Math.

mail me
Kees Couprie

Other pages by the same author.