Julian Date Number/Gregorian Calendar Date Conversions
01-14-2019, 01:21 AM (This post was last modified: 01-16-2019 02:41 PM by Eddie W. Shore.)
Post: #1
 Eddie W. Shore Senior Member Posts: 1,302 Joined: Dec 2013
Julian Date Number/Gregorian Calendar Date Conversions
HP Prime Program JD: Gregorian Date to Julian Date Number
Arguments: four digit year, month, day
JD(y,m,d)
Code:
 EXPORT JD(y,m,d) BEGIN // Gregorian to Julian // year, month, day // 2019-01-12 EWS //  Wikipedia LOCAL x0:=IP((m-14)/12); LOCAL x1:=IP(((1461*(y+4800+x0))/4)); LOCAL x3:=IP(367*(m-2-12*x0)/12); LOCAL x5:=IP((y+4900+x0)/100); LOCAL x6:=IP(3*x5/4); LOCAL j:=x1+x3-x6+d-32075; RETURN j; END;

HP Prime Program GREG: Julian Date Number to Gregorian Date
Argument: Julian Date Number
GREG(j)

Code:
EXPORT GREG(j) BEGIN // Julian to Gregorian // Wikipedia // 2019-01-12 EWS LOCAL x1:=IP((4*j+274277)/146097); LOCAL x2:=IP(x1*3/4); LOCAL f:=j+1401+x2-38; LOCAL E:=4*f+3; LOCAL G:=IP((E MOD 1461)/4); LOCAL H:=5*G+2; LOCAL D:=IP((H MOD 153)/5)+1; LOCAL M:=((IP(H/153)+2) MOD 12)+1; LOCAL Y:=IP(E/1461)-4716+IP((12+2-M)/12); RETURN {Y,M,D}; END;

Examples

Gregorian Date: 1988, October 31
JD: 2447466

Gregorian Date: 1999, January 11
JD: 2451190

Gregorian Date: 2017, March 21
JD: 2457834

Source:

"Julian Day" Wikipedia. Edited (when retrieved) November 19, 2018. Retrieved January 11, 2019. https://en.wikipedia.org/wiki/Julian_day