Wednesday, February 11, 2015

HP Prime, HP 42S, HP 12C: Julian Date

The following program calculates the Julian Date given:

M = month

D = day
Y = year, four digits
UT = Universal Time.  The universal time is notated by 0:00 to 24:00, as the current time at the Greenwich Mean Time.  Depending on where you live, it may be necessary to adjust the current time in your time zone to get Greenwich Mean Time.  For example, add 8 hours to the Pacific Standard Time, and add 7 hours to the Pacific Daylight Savings time, to get the equivalent Greenwich Mean Time for the Pacific Time Zone.  You may have to adjust the day number by 1 (either way) as a consequence. 

Formula for the Julian Date:


j:=367*Y-IP(7*(Y+IP((M+9)/12))/4)

-IP(3*(IP((Y+(M-9)/7)/100)+1)/4)

+IP(275*M/9)+D+1721028.5+H/24

where IP is the integer function.  The integer function is also symbolized by INT, INTG, and iPart.  This is the most complete formula, as there are shortcut formulas for Julian Date.


Source for formula:  http://scienceworld.wolfram.com/astronomy/JulianDate.html 


Here are the programs for Julian Date for three different HP calculators:  HP Prime, HP 42S, and HP 12C.


My thanks to Jason Foose who traded with me, I now have a 42S.  He asked to trade me for my one of my 50g's.  


Julian Date:  HP Prime


EXPORT JULIAN(M,D,Y,H)

BEGIN
// wolfram.com
// 2015-02-08
// H UT time
// +8 PST +7 PDT
LOCAL j;
j:=367*Y-IP(7*(Y+IP((M+9)/12))/4)
-IP(3*(IP((Y+(M-9)/7)/100)+1)/4)
+IP(275*M/9)+D+1721028.5+H/24;
RETURN j;

END;

Julian Date:  HP 42S


Before running the program "JD", store the following:

Month (M) to Memory 01
Day (D) to Memory 02
Year (Y) to Memory 03
Universal Time (H) to  Memory 04

The Julian Date is stored in Memory 00.

(edited 2/13/2015 - thanks Mike)

00   { 102-Byte Prgm }

01   LBL "JD"
02   367
03   RCLx 03
04   STO 00
05   9
06   RCL+ 01
07   12
08   ÷
09   IP
10   RCL+ 03
11   7
12   x
13   4
14   ÷
15   IP
16   STO- 00
17   -9
18   RCL+ 01
19   7
20   ÷
21   RCL+ 03
22   100
23    ÷
24    IP
25    1
26    +
27    0.75
28    x
29    IP
30    STO- 00
31    275
32    RCLx 01
33    9
34    ÷
35   IP
36   STO+ 00
37   RCL 00
38   RCL+ 02
39   1721028.5
40   +
41   RCL 04
42   24
43   ÷
44    +
45   STO 00
46   RCL 00
47  .END.

Examples:

January 7, 2015;  12:35 UT
M = 1, D = 7, Y = 2015,  H = 12.58333333

Result:  JD = 2,457,030.02431

December 17, 2230;  18:30 UT
M = 12, D = 17, Y = 2230, H = 18.5

Result:  JD = 2,535,901.27083


Julian Date:  HP 12C

This program uses the ΔDYS function.  Universal time is assumed to be 12:00.  

Step    Key    Key Code
01       1         1
02       .          48
03       0         0
04       1         1 
05       2         2
06       x<>y   34
07       ΔDYS 43 26
08       2         2 
09       4         4
10       5         5
11       1         1
12       5         5
13       4         4
14       5         5
15       +        40


Examples:

June 30, 2016;   JD = 2,457,570

October 31, 2111:  JD = 2,492,390

Hopefully this program will be helpful.  Until next time,

Eddie



This blog is property of Edward Shore.  2015




2 comments:

  1. There's an error In the HP-42S program. Line 38 should be:

    38 RCL+ 02

    ReplyDelete
    Replies
    1. Thanks - Mike. The blog is now corrected.

      Eddie

      Delete

HP Prime and TI-84 Plus: Basic Wheatstone Full Bridge Circuit

HP Prime and TI-84 Plus:  Basic Wheatstone Full Bridge Circuit The program WHEATSTONE (HP Prime) and WHTSTONE (TI-84 Plus CE) deals wi...