Expand range of DATE functions?

This is where developers can exchange ideas and ask questions relevant to the DM42 firmware.

Please note that Swiss Micros staff are unable to provide answers here as a general rule. This is intended as a community-driven forum.
rudi
Posts: 52
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

Expand range of DATE functions?

I don't know if this is the right forum to ask, but I would like that the DM42 DATE function ranges are expanded from the range inherited from the HP-41 CX.
The 41CX manual states at p. 66:
https://literature.hpcalc.org/community/hp41cx-om-vol1-en.pdf wrote:Calendar Functions
Any date from October 15, 1582 (the beginning of the Gregorian calendar) through September 10, 4320
is valid for calculations with dates.
I am implementing a program to convert a date into Julian Date. And by using the DDAYS function, this can be done very simple:

Code: Select all

01 LBL "→JD"
02 1,012
03 DDAYS
04 2451545
05 +
06 END

However, this code is limited by the DATE function ranges as quoted above, and I sometime have to make calculations for dates before 1582.
I have also implemented an algorithm described in "Astronomical Formulæ for Calculators" by Jean Meeus, which practically has no limits (only number representation), this program takes up ca 50 lines of code - 10 times as long as the above.

I appologize, if this is not the right place to ask, maybe another forum here on SwissMicros? Or perhaps at Free42 github?
I also appologize to @rprosperi, if this matter has already been adressed, I have done my best to search this forum about it, but without any luck. I hope I'm still relatively new here in bob's eyes

I understand, that it is important to maintain as close to 100% compatability with the HP42 and HP41CX (Time module) as possible, but will it make a difference to expand the valid date range?
/Rudi

DM-42 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV and ex HP-75C + a lot, really lot of a accessories)
Thomas Okken
Posts: 978
Joined: Tue May 02, 2017 5:48 pm
Location: The Netherlands
Contact:

Re: Expand range of DATE functions?

I made the DOW, DATE+, and DDAYS functions work in the 10/15/1582-9/10/4320 date range because that's what they do in the HP-82182A Time Module and on the HP-41CX, but I see no reason not to expand that range all the way to account for the full range allowed by the date representation in use, i.e. 1/1/1 through 12/31/9999.

Mathematically, I believe it's pretty straightforward; the Gregorian calendar was designed to be very accurate, so there's no reason we can foresee why it wouldn't still be in use 8000 years from now, and the past history of the Roman calendar is pretty well documented, so the Julian calendar could be assumed for the range until 10/4/1582, the only quirks I'm aware of being the missing leap day in 4 AD, and the 10 days that were dropped from October 1582.
Walter
Posts: 2132
Joined: Tue May 02, 2017 11:13 am
Location: Close to FRA, Germany

Re: Expand range of DATE functions?

There is a little sketch of the facts on p. 193 of the 43S Owner's Manual. Just FYI.
DM42 SN: 00041 β
WP 43S running on this device

HP-35, HP-45, ..., HP-35S; WP 34S & WP 31S for obvious reasons; DM16L
Peet
Posts: 181
Joined: Tue Sep 29, 2020 12:01 am
Location: Germany

Re: Expand range of DATE functions?

Thomas Okken wrote:
Tue Nov 30, 2021 9:14 am
...the Gregorian calendar was designed to be very accurate, so there's no reason we can foresee why it wouldn't still be in use 8000 years from now,....
The exactness is only accurate to 3 places after the decimal point, according to John Herschel, an adjustment will be necessary again in approx. 4000 years.
My programmable calculators - former: CBM PR100, HP41CV, HP28S, HP11C - current: HP48G(256kB), HP35S, Prime, DM41X, DM42
rudi
Posts: 52
Joined: Wed Nov 03, 2021 9:03 am
Location: Denmark
Contact:

Re: Expand range of DATE functions?

Thomas Okken wrote:
Tue Nov 30, 2021 9:14 am
I made the DOW, DATE+, and DDAYS functions work in the 10/15/1582-9/10/4320 date range because that's what they do in the HP-82182A Time Module and on the HP-41CX, but I see no reason not to expand that range all the way to account for the full range allowed by the date representation in use, i.e. 1/1/1 through 12/31/9999.

Mathematically, I believe it's pretty straightforward; the Gregorian calendar was designed to be very accurate, so there's no reason we can foresee why it wouldn't still be in use 8000 years from now, and the past history of the Roman calendar is pretty well documented, so the Julian calendar could be assumed for the range until 10/4/1582, the only quirks I'm aware of being the missing leap day in 4 AD, and the 10 days that were dropped from October 1582.
Below is a listing of the algorithm in the mentioned book. It's still work in progress, can probably be optimized.
I will check if this algorithm can handle the challenges you mention Thomas Okken.

Code: Select all

@ Date to Julian Days by Rudi Bjørn Rasmussen
@ Implementation of algorithm in "Astronomical Formulæ for Calculators" by Jean Meeus p. 24
@ Input date format: MM.DDYYYY
@	MM is the month, 1-12
@	DD is the date, 1-31
@	YYYY is the year 0-9999
01 LBL "JD"
02 ENTER
03 IP
04 STO 00
05 -
06 1ᴇ2
07 ×
08 ENTER
09 IP
10 STO 01
11 -
12 1ᴇ4
13 ×
14 IP
15 STO 02
16 RCL 00
17 1ᴇ-2
18 ×
19 +
20 RCL 01
21 1ᴇ-4
22 ×
23 +
24 STO 03
25 RCL 00
26 2
27 X<Y?
28 GTO 00
29 1
30 STO- 02
31 12
32 STO+ 00
33 LBL 00
34 365.25
35 RCL× 02
36 IP
37 1
38 RCL+ 00
39 30.6001
40 ×
41 IP
42 +
43 RCL+ 01
44 1720994.5
45 +
46 STO 00
47 RCL 03
48 1582.1015
49 X>Y?
50 GTO 01
51 RCL 02
52 1ᴇ2
53 ÷
54 IP
55 ENTER
56 ENTER
57 4
58 ÷
59 IP
60 -
61 +/-
62 2
63 +
64 STO+ 00
65 LBL 01
66 RCL 00
67 RTN
68 END
/Rudi

DM-42 (s/n 06999), HP-42S, HP-35s, HP-11c, HP-32SII (ex HP-41CV and ex HP-75C + a lot, really lot of a accessories)