Julian Date Number/Gregorian Calendar Date Conversions

01142019, 01:21 AM
(This post was last modified: 01162019 02:41 PM by Eddie W. Shore.)
Post: #1




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:
HP Prime Program GREG: Julian Date Number to Gregorian Date Argument: Julian Date Number GREG(j) Code: EXPORT GREG(j) 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 Blog post link: https://edspi31415.blogspot.com/2019/01/...cg50.html 

01142019, 12:01 PM
(This post was last modified: 01142019 01:16 PM by Dieter.)
Post: #2




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01142019 01:21 AM)Eddie W. Shore Wrote: HP Prime Program JD: Gregorian Date to Julian Date Number Eddie, there is no need to calculate this manually with lots of formulas. You can do this with the Prime's builtin calendar functions: For the Julian day number simply determine the date difference to 15821015 and add 2299161. For the Gregorian date subtract 2299161 from the Julian day number and add this number of days to 15821015. You will know the correct Prime syntax for this. ;) Edit: I have just posted a short 12C program using this approach in the General Software Library. In both cases the date may not be earlier than Oct 15, 1982. This is the first day of the Gregorian calendar, earlier Gregorian dates simply do not exist. If you run your program with an earlier date the result will be invalid – the program works as if the Gregorian calendar existed before the mentioned date (proleptic calendar). I don't know how the Prime behaves in this regard. Does it return an error for earlier dates? (01142019 01:21 AM)Eddie W. Shore Wrote: Examples Sorry, that's wrong. The JDN for this date is 2451118. 2447466 is the JDN of 31 Oct 1988. Dieter 

01142019, 11:13 PM
Post: #3




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01142019 12:01 PM)Dieter Wrote: I don't know how the Prime behaves in this regard. Does it return an error for earlier dates? Yes. It says "Error: Invalid input" for date inputs (or results) outside the range [1582.1015, 9999.1231]. <0ɸ0> Joe 

01162019, 02:48 PM
(This post was last modified: 01162019 02:53 PM by Eddie W. Shore.)
Post: #4




RE: Julian Date Number/Gregorian Calendar Date Conversions
Dieter,
I meant 1988, not 1998. Typo on my end. The post was on my blog (see the link in the original post) is for three calculators, not just for the HP Prime. I wanted to get an algorithm down to include code for any calculators that don't have the wonderful DDAYS and DATEADD/DATE+ functions that HP Prime, and most highend HP calculators have. Quite frankly, the DDAYS and DATEADD should be on every calculator. In future programs, especially on the HP Prime, I will use these functions. The DDAYS function is one of my most used and favorite functions! 

01162019, 08:18 PM
Post: #5




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01162019 02:48 PM)Eddie W. Shore Wrote: Quite frankly, the DDAYS and DATEADD should be on every calculator. In future programs, especially on the HP Prime, I will use these functions. Interesting that the Prime manual refers only to DateDays (the Finance app function), and DELTADAYS (Catalog) and not DDAYS. Looks like the latter was renamed but the change didn't make the manual? Cambridge, UK 41CL, 12C/15C, DM15/16, 71B, 17B, 28S, DM42, 48GX, 17bII+, 50g (& newRPL), 35s, 30b (WP 34S), Prime G2 & Casios, Rockwell 18R :) 

03072019, 07:17 PM
(This post was last modified: 03092019 02:00 AM by Albert Chan.)
Post: #6




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01142019 01:21 AM)Eddie W. Shore Wrote: Gregorian Date: 1999, January 11 If we also know what weekday the date is, we can get JDN easily: Using Rata Die calendar days (proleptic Gregorian date Jan 1, 0001 (Monday) as day 1) RD ≈ round(((y1) + (m1)/12) * 365.2425) + (d1) max error ±2 days, removed by matching actual weekdays. JDN = 1721425 + RD A quick way to do modulo 7, using 10 ≡ 3, 10² ≡ 2, 10³ ≡ 1 (mod 7) Example: 123456789 (mod 7) ≡ 123  456 + 789 ≡ 456 ≡ 2*4 + 3*5 + 6 ≡ 1 + 1  1 ≡ 1 For 1999, January 11, Monday: RD ≈ round((1998 + 0/12) * 365.2425) + 10 ≈ 729765 729765 (mod 7) ≡ 765  729 ≡ 36 ≡ 1 (matched Monday) > JDN = 1721425 + 729765 = 2451190 For 2017, March 21, Tuesday: RD ≈ round((2016 + 2/12) * 365.2425) + 20 ≈ 736410 736410 (mod 7) ≡ 410  736 ≡ 2(47) + 3(13)  6 ≡ 1 + 1 + 1 ≡ 3 (should be Tuesday) > RD = 736410  1 = 736409 > JDN = 1721425 + 736409 = 2457834 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)