Sunday, May 19, 2013

HP15C: Julian Date from Gregorian Date

Thanks to the University of Texas at San Antonio Computer Science Department. The explanation and formulas can be found by clicking on this link.

Note: This program only works for dates on or after October 15, 1582. Thank you Dieter.


Calculator
HP 15C (can be adopted with any RPN keystroke calculator)

Input
Preload the following information into these registers:
R1 = month (1 for January, 12 for December)
R2 = date
R3 = year in four digits (example: 2013)

Output
R0 = Julian Date

Temporary
R4 = a = integer((14-month)/12)
R5 = y = year + 4800 - a

Formulas
(See link above)
a = integer((14-month)/12)
y = year + 4800 - a
m = month + 12a - 3
Julian Date = day + integer((153m+2)/5) + 365y + integer(y/4) - integer(y/100) + integer(y/400) - 32045

Assumptions: 12:00 PM Universal Time is assumed (that's 7:00 AM in Pacific Standard Time or 8:00 AM in Pacific Daylight Savings Time)

Program
LBL A
1
4
RCL - 1
1
2
÷
INT
STO 4
4
8
0
0
RCL + 3
RCL - 4
STO 5
RCL 2
STO 0
1
2
RCL × 4
RCL + 1
3
-
1
5
3
×
2
+
5
÷
INT
STO + 0
3
6
5
RCL × 5
STO + 0
RCL 5
4
÷
INT
STO + 0
RCL 5
1
%
CHS
INT
STO + 0
RCL 5
4
÷
1
%
INT
STO + 0
RCL 0
3
2
0
4
5
-
STO 0
RTN


In HP RPN calculators, a number followed by 1, %, divides said number by 100.

Example:

March 14, 1977 has a Julian Date of 2,443,217
April 28, 2012 has a Julian Date of 2,456,046
December 31, 2015 has a Julian Date of 2,457,388

This blog is property of Edward Shore. 2013



TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...