time and date math
time and date math
does anyone know of any time and date math programs for the DM42 (adding/subtracting days/time)?
DM41X, DM42, HP33c, DM41
in the past: HP34C, HP41CX, HP48GX, HP32S, HP42s
Re: time and date math
Coincidentally, I wrote a post about your question earlier today! However, I am new to the forums (I received my DM42 only two weeks ago), so my post is waiting in the queue to be approved by a moderator.
Here is a partial answer to your question: the DM42 already has time and date functions. They are named and descrribed on the Free42 website: https://thomasokken.com/free42/#time . You can access them with [CATALOG] -> [FCN]... it's easier to use the scroll-up button from there, because they appear at the end of the list.
I say this is only a partial answer because I myself cannot figure out how to use these time and date fucntions. Here is my original post from earlier today, which might appear at a later time:
...
I have had my DM42 (S/N 05503) for a couple of weeks. It's been more than a quarter century since I've used a similar calculator (HP-48), so there's a lot for me to remember, understand, and explore.
One thing I don't understand: the time and date functions, which are Free42 extensions to the HP-42S functions.
When I call the DATE function, the X-register is:
2,020.0813
This is exactly what I expected. I prefer YMD, and the top strip om my calculator displays 2020-08-13.
However, when I call the DOW function when this number is in the X-register, I get:
Invalid Data
when I expected THU
Similarly, when I call DATE+ with 2,020.0813 in the Y-register and 10 in the X-register, I get:
Invalid Data
when I expected 2,020.0823
And when I call DDATE with 2,020.0813 in the Y-register rand 2,020.0814 in the Y-regsiter:
Invalid Data
when I expected 1
I'm not understanding something fundamental here... what am I doing wrong? Thank you.
Here is a partial answer to your question: the DM42 already has time and date functions. They are named and descrribed on the Free42 website: https://thomasokken.com/free42/#time . You can access them with [CATALOG] -> [FCN]... it's easier to use the scroll-up button from there, because they appear at the end of the list.
I say this is only a partial answer because I myself cannot figure out how to use these time and date fucntions. Here is my original post from earlier today, which might appear at a later time:
...
I have had my DM42 (S/N 05503) for a couple of weeks. It's been more than a quarter century since I've used a similar calculator (HP-48), so there's a lot for me to remember, understand, and explore.
One thing I don't understand: the time and date functions, which are Free42 extensions to the HP-42S functions.
When I call the DATE function, the X-register is:
2,020.0813
This is exactly what I expected. I prefer YMD, and the top strip om my calculator displays 2020-08-13.
However, when I call the DOW function when this number is in the X-register, I get:
Invalid Data
when I expected THU
Similarly, when I call DATE+ with 2,020.0813 in the Y-register and 10 in the X-register, I get:
Invalid Data
when I expected 2,020.0823
And when I call DDATE with 2,020.0813 in the Y-register rand 2,020.0814 in the Y-regsiter:
Invalid Data
when I expected 1
I'm not understanding something fundamental here... what am I doing wrong? Thank you.
-
- Posts: 1102
- Joined: Tue May 02, 2017 5:48 pm
- Location: Netherlands
- Contact:
Re: time and date math
Adding and subtracting dates can be accomplished using the built-in functions DATE+ and DDAYS; see https://thomasokken.com/free42/#time
Adding and subtracting times can be accomplished using the built-in functions HMS+ and HMS-; those are covered in the HP-42S manual, see https://thomasokken.com/free42/#doc
Adding and subtracting times can be accomplished using the built-in functions HMS+ and HMS-; those are covered in the HP-42S manual, see https://thomasokken.com/free42/#doc
Re: time and date math
Thank you both very much! I used the HP41CV extensively, but almost 40 years ago - I've slept since then and my programming skills are very rusty.
DM41X, DM42, HP33c, DM41
in the past: HP34C, HP41CX, HP48GX, HP32S, HP42s
-
- Posts: 1102
- Joined: Tue May 02, 2017 5:48 pm
- Location: Netherlands
- Contact:
Re: time and date math
SwissMicros will have to weigh in on that one. The DATE+ and DDAYS functions work fine in Free42, and also on my DM42, running DM42 3.15 and DMCP 3.17.WLVA wrote: ↑Thu Aug 13, 2020 10:53 pm
One thing I don't understand: the time and date functions, which are Free42 extensions to the HP-42S functions.
When I call the DATE function, the X-register is:
2,020.0813
This is exactly what I expected. I prefer YMD, and the top strip om my calculator displays 2020-08-13.
However, when I call the DOW function when this number is in the X-register, I get:
Invalid Data
when I expected THU
Similarly, when I call DATE+ with 2,020.0813 in the Y-register and 10 in the X-register, I get:
Invalid Data
when I expected 2,020.0823
And when I call DDATE with 2,020.0813 in the Y-register rand 2,020.0814 in the Y-regsiter:
Invalid Data
when I expected 1
I'm not understanding something fundamental here... what am I doing wrong? Thank you.
Re: time and date math
This was just answered in the Problem Reports section. Please don't post the same problem in more than 1 location; it makes it difficult for people to follow issues and answers. Suggest you go to the other thread and continue the discussion there.WLVA wrote: ↑Thu Aug 13, 2020 10:53 pm
One thing I don't understand: the time and date functions, which are Free42 extensions to the HP-42S functions.
When I call the DATE function, the X-register is:
2,020.0813
This is exactly what I expected. I prefer YMD, and the top strip om my calculator displays 2020-08-13.
However, when I call the DOW function when this number is in the X-register, I get:
Invalid Data
when I expected THU
Similarly, when I call DATE+ with 2,020.0813 in the Y-register and 10 in the X-register, I get:
Invalid Data
when I expected 2,020.0823
And when I call DDATE with 2,020.0813 in the Y-register rand 2,020.0814 in the Y-regsiter:
Invalid Data
when I expected 1
I'm not understanding something fundamental here... what am I doing wrong? Thank you.
--bob p
DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
Re: time and date math
I'll pick this up in the other topic.Thomas Okken wrote: ↑Fri Aug 14, 2020 9:06 pmSwissMicros will have to weigh in on that one. The DATE+ and DDAYS functions work fine in Free42, and also on my DM42, running DM42 3.15 and DMCP 3.17.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Re: time and date math
Thanks for the redirect.
Despite the timestamps, my original post (in the Problem Reports section) didn't exist when I posted my reply here, because it was being held up in the moderator queue. Being new here, I had no idea how long it would take for that to clear, and I believed I had something relevant and timely to add to this discussion. Of course, I then discovered to my chagrin that replying to this thread also required moderator approval.
I apologize for posting my issue twice. For those coming to this late, here is where the discussion is continuing:
viewtopic.php?f=17&t=2528
Re: time and date math
Not a problem at all and thanks for explaining. The delay upon making initial posts can lead that, you're not the first by far.
Bonus is you found a genuine Free42 bug - something rare and worthy of note. I had actually forgotten that the date format settings in the setup menu affected the Free42/DM42 running behavior; I use these for setting the status line behavior, and use the 41-style commands to set the operating behavior (as I'm familiar with them from years of using a 41), which is why it appeared there was no problem. Thanks for contributing!
Bonus is you found a genuine Free42 bug - something rare and worthy of note. I had actually forgotten that the date format settings in the setup menu affected the Free42/DM42 running behavior; I use these for setting the status line behavior, and use the 41-style commands to set the operating behavior (as I'm familiar with them from years of using a 41), which is why it appeared there was no problem. Thanks for contributing!
--bob p
DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
DM42: β00071 & 00282, DM41X: β00071 & 00656, DM10L: 071/100
Re: time and date math
As it happens, I used the following to determine when to check my DM42 for clock drift, after 2 million seconds:
DATE/TIME + n seconds
In:
Z: Date (current format)
Y: Time HH.MMSS
X: n (number of seconds)
Out:
Y: Date (current format)
X: Time HH.MMSS
For now it only works for adding seconds, so n>=0
I set the correct time on 29 July at 9:33, and I use Y.MD mode, so to determine when 2 million seconds have passed:
Z: 2020.0729
Y: 9.33
X: 2E6
XEQ "DTS+"
->
Y: 2020.0821
X: 13.0620
Also, at the hpmuseum, I just launched a small challenge, to write ->DATE and DATE-> functions that would assemble and disassemble dates to/from the current format from/into YYYY, MM and DD, the results: (first routine by Didier Lachieze explicitly relies on F31 being clear when F67 is set, though, so use the FCN set to change date formats, not the DM2 Settings menu).
Cheers, Werner
DATE/TIME + n seconds
In:
Z: Date (current format)
Y: Time HH.MMSS
X: n (number of seconds)
Out:
Y: Date (current format)
X: Time HH.MMSS
Code: Select all
00 { 38-Byte Prgm }
01▸LBL "DTS+"
02 3600
03 ÷
04 X<>Y
05 →HR
06 +
07 24
08 ÷
09 DATE+
10 LASTX
11 FP
12 24
13 ×
14 →HMS
15 1ᴇ30 @ H.MS round
16 HMS+
17 LASTX
18 -
19 END
I set the correct time on 29 July at 9:33, and I use Y.MD mode, so to determine when 2 million seconds have passed:
Z: 2020.0729
Y: 9.33
X: 2E6
XEQ "DTS+"
->
Y: 2020.0821
X: 13.0620
Also, at the hpmuseum, I just launched a small challenge, to write ->DATE and DATE-> functions that would assemble and disassemble dates to/from the current format from/into YYYY, MM and DD, the results: (first routine by Didier Lachieze explicitly relies on F31 being clear when F67 is set, though, so use the FCN set to change date formats, not the DM2 Settings menu).
Code: Select all
00 { 30-Byte Prgm }
01▸LBL "→DATE"
02 FS? 31
03 X<>Y
04 FC? 67
05 RCL ST Z
06 100
07 FC? 67
08 STO÷ ST Y
09 STO÷ ST Z
10 X↑2
11 ÷
12 +
13 +
14 END
Code: Select all
00 { 35-Byte Prgm }
01 LBL "DATE→"
02 IP
03 LASTX
04 FP
05 100
06 x
07 IP
08 LASTX
09 FP
10 100
11 x
12 FS? 67
13 RTN
14 LASTX
15 x
16 X<> ST Z
17 FC? 31
18 X<>Y
19 END
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L