INT(x) = [x] NOTE: some computer languages have a different definition.
FIX(x) = the number x without its fraction. For example, FIX(-1.5)=-1
x\y = FIX(x/y)
IF M < 3 THEN
M = M + 12
Y=Y-1
END IF
JD = D + (153 * M - 457) \ 5 + 365 * Y + [Y / 4] - [Y / 100] + [Y / 400] + 1721118.5
COMMENTS:
SUB jdg (jd AS DOUBLE, y1 AS LONG, m1 AS INTEGER, d AS DOUBLE)
y& = y1 'don't modify year input parameter
m% = m1 'don't modify month input parameter
IF m% < 3 THEN 'months are January or February
m% = m% + 12 'January=13, February=14
y& = y& - 1 'of the previous year
END IF 'months are January or February
jd=d#+(153*m%-457)\5+INT(365.25#*y&)-INT(y&*.01#)+INT(y&*.0025#)+1721118.5#
END SUB
Since 365.25*4716 = 1,722,519.0,
and 30.6001(m+1)) = FIX(30.6001*m - 91.4) + 122,
and FIX(FIX(y/100)/4) = FIX(Y/400),
and since 1,722,519.0 + 122 + 2 - 1524.5 = 1721118.5,
this is equivalent to our derived algorithm provided the years are positive.
COMMENTS:
Here the expression:
(M - 14)\12
is used to implement the conditional change of Y and M that can be more clearly expressed as:
With this change in the values of M and Y,
JD=(1461*(Y+4800))\4+(367*(M-2))\12-(3*((Y+4900)\100))\4+D-32075
Assume Y is non-negative (or use INT instead of FIX in the following argument). The following identities can be shown to hold:
COMMENTS:
COMMENTS:
SUB jdj (jd AS DOUBLE, y1 AS LONG, m1 AS INTEGER, d AS DOUBLE)
'***WARNING**** Input Date is Julian, NOT Gregorian
y& = y1 'don't modify year input parameter
m% = m1 'don't modify month input parameter
IF m% < 3 THEN 'months are January or February
m% = m% + 12 'January=13, February=14
y& = y& - 1 'of the previous year
END IF 'months are January or February
jd=d#+(153*m%-457)\5+INT(365.25#*y&)+1721116.5#
END SUB
Since 365.25*4716 = 1,722,519.0,
and 30.6001(M + 1)) = FIX(30.6001*M - 91.4) + 122,
and since 1,722,519.0 + 122 -1524.5 = 1721116.5,
this is equivalent to our derived algorithm provided the years are not less than -4716. This is assured if the JD is non-negative since JD = 0.0 occurred at noon on January 1, -4712 in the Julian Calendar.
COMMENTS:
Last Modified: June 14, 2001