free42 Date Tools
Author: | Mitch Richling |
Updated: | 2025-10-08 14:50:04 |
Copyright 2025 Mitch Richling. All rights reserved.
Table of Contents
1. Metadata
- Connonical URL for this file: https://richmit.github.io/hp42/date.html
- org-mode file source for this file: https://github.com/richmit/hp42/blob/master/src/date.org
- 42s code listings in this file: https://github.com/richmit/hp42/blob/master/src_42s/date/date.hp42s
- GitHub repository: https://github.com/richmit/hp42
2. Introduction
Aside from the date/time conversion routines, the rest is just wrappers for built in functions to make them print results when called from a program. Why? I
wanted to put things like DATE
in a nested custom menu, and have them print the date just as if I had directly put the function in a custom menu. ;) Now
that free42 has put these into a separate catalog menu, these are somewhat obsolete.
4. Menu Code
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (DMENU) @@@@ DSC: Auto-generated menu program LBL "DMENU" LBL 01 @@@@ Page 1 of menu DMENU CLMENU "DATE" KEY 1 XEQ 95 "TIME" KEY 2 XEQ 88 "UTIME" KEY 3 XEQ "UTIME" "DT→U" KEY 5 XEQ "DT→U" "U→DT" KEY 6 XEQ "U→DT" KEY 7 GTO 03 KEY 8 GTO 02 KEY 9 GTO 00 MENU STOP GTO 01 LBL 02 @@@@ Page 2 of menu DMENU CLMENU "DATE" KEY 1 XEQ 95 "JDATE" KEY 3 XEQ "JDATE" "D→J" KEY 5 XEQ "D→J" "J→D" KEY 6 XEQ "J→D" KEY 7 GTO 01 KEY 8 GTO 03 KEY 9 GTO 00 MENU STOP GTO 02 LBL 03 @@@@ Page 3 of menu DMENU CLMENU "DATE+" KEY 1 XEQ 92 "DDAYS" KEY 2 XEQ 04 "DOW" KEY 3 XEQ 91 KEY 7 GTO 02 KEY 8 GTO 01 KEY 9 GTO 00 MENU STOP GTO 03 LBL 00 @@@@ Application Exit EXITALL RTN LBL 04 @@@@ Action for menu key DDAYS DDAYS RTN @@@@ Free labels start at: 5
5. Application Local Subroutines
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Interactive Current Date @@@@ NAM: IDATE @@@@ OUT: X: Date encoded as a real @@@@ SFX: Prints date even when called from a program @@@@ UPD: 2025-10-07 LBL 95 FUNC 01 L4STK DATE "Date: " ADATE AVIEW RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Interactive Current Time @@@@ NAM: ITIME @@@@ OUT: X: Time in H.MM.SS format @@@@ SFX: Prints time even when called from a program @@@@ UPD: 2025-10-07 LBL 88 FUNC 01 L4STK TIME "Time: " ATIME AVIEW RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Current UNIX time @@@@ OUT: X: UNIX time @@@@ UPD: 2025-10-07 LBL "UTIME" FUNC 02 L4STK DATE TIME XEQ "DT→U" RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Convert date & time to UNIX time @@@@ IN: Y: Date @@@@ IN: X: Time @@@@ OUT: X: UNIX time @@@@ UPD: 2025-10-07 LBL "DT→U" FUNC 21 L4STK FS? 67 @@@@ In Y.MD mode 1970.0101 FC? 67 @@@@ Not in Y.MD mode 1.011970 @@@@ Works for M.DY & D.MY RCL ST Z DDAYS 24 × X<>Y →HR + 3600 × RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Interactive U→DT (prints date & time) @@@@ IN: X: UNIX time @@@@ OUT: Y: Date @@@@ OUT: X: Time @@@@ SFX: Prints date & time even when called from a program @@@@ UPD: 2025-10-07 LBL "U→DT" FUNC 12 L4STK 3600 ÷ RCL ST X 24 ÷ IP FS? 67 @@@@ In Y.MD mode 1970.0101 FC? 67 @@@@ Not in Y.MD mode 1.011970 @@@@ Works for M.DY & D.MY X<>Y DATE+ X<>Y 24 MOD →HMS X<>Y "Date: " ADATE X<>Y ├"[LF]Time: " ATIME AVIEW RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Interactive DATE+ (prints date) @@@@ NAM: IDATE+ @@@@ IN: Y: Date @@@@ IN: X: Integer @@@@ OUT: X: Date + Integer @@@@ UPD: 2025-10-07 LBL 92 FUNC 21 L4STK DATE+ "Date: " ADATE AVIEW RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Interactive DOW (prints day) @@@@ NAM: IDOW @@@@ IN: X: Date @@@@ OUT: X: Integer @@@@ SFX: Prints day of week even when called from a program @@@@ UPD: 2025-10-07 LBL 91 FUNC 11 L4STK DOW "Day of Week: " 70 + XEQ IND ST X AVIEW RTN LBL 70 ├"SUN" RTN LBL 71 ├"MON" RTN LBL 72 ├"TUE" RTN LBL 73 ├"WED" RTN LBL 74 ├"THR" RTN LBL 75 ├"FRI" RTN LBL 76 ├"SAT" RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Today's Julian day @@@@ OUT: X: Julian day for today @@@@ UPD: 2025-10-07 LBL "JDATE" FUNC 01 L4STK DATE XEQ "D→J" RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Interactive J→D (prints date) @@@@ NAM: J→D @@@@ IN: X: Date @@@@ OUT: X: Julian day @@@@ UPD: 2025-10-07 LBL "J→D" FUNC 11 L4STK 2440587.5 - FS? 67 @@@@ In Y.MD mode 1970.0101 FC? 67 @@@@ Not in Y.MD mode 1.011970 @@@@ Works for M.DY & D.MY X<>Y DATE+ "Date: " ADATE AVIEW RTN @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@ DSC: Today's Julian day @@@@ NAM: D→J @@@@ OUT: X: Julian day for today @@@@ UPD: 2025-10-07 LBL "D→J" FUNC 11 L4STK FS? 67 @@@@ In Y.MD mode 1970.0101 FC? 67 @@@@ Not in Y.MD mode 1.011970 @@@@ Works for M.DY & D.MY X<>Y DDAYS 2440587.5 + RTN END