October 26th, 2004, 9:56 am
Fliegel and van Flandern (1968) published compact computer algorithms for converting between Julian dates and Gregorian calendar dates. Their algorithms were presented in the Fortran programming language, and take advantage of the truncation feature of integer arithmetic. The following Fortran code modules are based on these algorithms. In this code, YEAR is the full representation of the year, such as 1970, 2000, etc. (not a two-digit abbreviation); MONTH is the month, a number from 1 to 12; DAY is the day of the month, a number in the range 1-31; and JD is the Julian date at Greenwich noon on the specified YEAR, MONTH, and DAY. Conversion from a Gregorian calendar date to a Julian date.Valid for any Gregorian calendar date producing a Julian date greater than zero: INTEGER FUNCTION JD (YEAR,MONTH,DAY)CC---COMPUTES THE JULIAN DATE (JD) GIVEN A GREGORIAN CALENDARC DATE (YEAR,MONTH,DAY).C INTEGER YEAR,MONTH,DAY,I,J,KC I= YEAR J= MONTH K= DAYC JD= K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) 2 /12-3*((I+4900+(J-14)/12)/100)/4C RETURN END Conversion from a Julian date to a Gregorian calendar date: SUBROUTINE GDATE (JD, YEAR,MONTH,DAY)CC---COMPUTES THE GREGORIAN CALENDAR DATE (YEAR,MONTH,DAY)C GIVEN THE JULIAN DATE (JD).C INTEGER JD,YEAR,MONTH,DAY,I,J,KC L= JD+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 K= L-2447*J/80 L= J/11 J= J+2-12*L I= 100*(N-49)+I+LC YEAR= I MONTH= J DAY= KC RETURN END Example: YEAR = 1970, MONTH = 1, DAY = 1, JD = 2440588.
Last edited by
GEL on October 25th, 2004, 10:00 pm, edited 1 time in total.