... | ... |
@@ -1,89 +1,84 @@ |
1 |
+( usage: uxncli datetime.rom ) |
|
2 |
+ |
|
3 |
+|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 |
|
1 | 4 |
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 |
2 | 5 |
|
3 | 6 |
|0100 |
4 | 7 |
|
5 |
- ( date ) |
|
6 |
- ;dict/date pstr |
|
7 |
- [ LIT2 00 -DateTime/dotw ] DEI #20 SFT ;week-txt ADD2 pstr |
|
8 |
- [ LIT2 20 ", ] #18 DEO #18 DEO |
|
9 |
- [ LIT2 00 -DateTime/month ] DEI #20 SFT ;month-txt ADD2 pstr |
|
10 |
- #2018 DEO |
|
11 |
- [ LIT2 00 -DateTime/day ] DEI pdec |
|
12 |
- [ LIT2 20 ", ] #18 DEO #18 DEO |
|
13 |
- .DateTime/year DEI2 pdec |
|
8 |
+@on-reset ( -> ) |
|
9 |
+ <print-date> |
|
14 | 10 |
#0a18 DEO |
15 |
- |
|
16 |
- ( time ) |
|
17 |
- ;dict/time pstr |
|
18 |
- [ LIT2 00 -DateTime/hour ] DEI pdec-pad |
|
19 |
- LIT ": #18 DEO |
|
20 |
- [ LIT2 00 -DateTime/minute ] DEI pdec-pad |
|
21 |
- LIT ": #18 DEO |
|
22 |
- [ LIT2 00 -DateTime/second ] DEI pdec-pad |
|
11 |
+ <print-time> |
|
12 |
+ #0a18 DEO |
|
13 |
+ <print-doty> |
|
23 | 14 |
#0a18 DEO |
24 |
- |
|
25 |
- ( doty ) |
|
26 |
- ;dict/doty pstr |
|
27 |
- .DateTime/doty DEI2 pdec |
|
28 |
- [ LIT2 0a ". ] #18 DEO #18 DEO |
|
29 | 15 |
#800f DEO |
30 |
- |
|
31 |
-BRK |
|
32 |
- |
|
33 |
-@pstr ( str* -- ) |
|
34 |
- |
|
35 |
- LDAk ?&w POP2 JMP2r |
|
36 |
- &w |
|
16 |
+ BRK |
|
17 |
+ |
|
18 |
+@<print-date> ( -- ) |
|
19 |
+ ;dict/date <print-str> |
|
20 |
+ [ LIT2 00 -DateTime/dotw ] DEI #20 SFT ;week-txt ADD2 <print-str> |
|
21 |
+ [ LIT2 20 ", ] #18 DEO |
|
22 |
+ #18 DEO |
|
23 |
+ [ LIT2 00 -DateTime/month ] DEI #20 SFT ;month-txt ADD2 <print-str> |
|
24 |
+ #2018 DEO |
|
25 |
+ [ LIT2 00 -DateTime/day ] DEI <print-dec> |
|
26 |
+ [ LIT2 20 ", ] #18 DEO |
|
27 |
+ #18 DEO |
|
28 |
+ .DateTime/year DEI2 !<print-dec> |
|
29 |
+ |
|
30 |
+@<print-time> ( -- ) |
|
31 |
+ ;dict/time <print-str> |
|
32 |
+ .DateTime/hour DEIk <print-dec-pad> |
|
33 |
+ [ LIT2 ": 18 ] DEO |
|
34 |
+ INC DEIk <print-dec-pad> |
|
35 |
+ [ LIT2 ": 18 ] DEO |
|
36 |
+ DEI !<print-dec-pad> |
|
37 |
+ |
|
38 |
+@<print-str> ( str* -- ) |
|
39 |
+ &w ( -- ) |
|
37 | 40 |
LDAk #18 DEO |
38 | 41 |
INC2 LDAk ?&w |
39 |
- POP2 |
|
40 |
- |
|
41 |
-JMP2r |
|
42 |
- |
|
43 |
-@pdec-pad ( byte -- ) |
|
44 |
- |
|
45 |
- #0a DIVk emit |
|
46 |
- DIVk MUL SUB emit |
|
47 |
- |
|
48 |
-JMP2r |
|
49 |
- |
|
50 |
-@pdec ( short* -- ) |
|
51 |
- |
|
52 |
- #00 ,&z STR |
|
53 |
- #2710 pdec/parse |
|
54 |
- #03e8 pdec/parse |
|
55 |
- #0064 pdec/parse |
|
56 |
- #000a pdec/parse |
|
57 |
- NIP emit |
|
58 |
- |
|
59 |
-JMP2r |
|
60 |
- |
|
61 |
-&parse ( short* den* -- short* ) |
|
62 |
- |
|
63 |
- DIV2k DUPk [ LIT &z $1 ] EQU ?&skip |
|
64 |
- DUP emit #ff ,&z STR |
|
65 |
- &skip POP MUL2 SUB2 |
|
66 |
- |
|
67 |
-JMP2r |
|
68 |
- |
|
69 |
-@emit ( num -- ) |
|
70 |
- |
|
42 |
+ POP2 JMP2r |
|
43 |
+ |
|
44 |
+@<print-doty> ( -- ) |
|
45 |
+ ;dict/doty <print-str> |
|
46 |
+ .DateTime/doty DEI2 |
|
47 |
+ ( >> ) |
|
48 |
+ |
|
49 |
+@<print-dec> ( short* -- ) |
|
50 |
+ #2710 [ LIT2r 00fb ] |
|
51 |
+ &w ( -- ) |
|
52 |
+ DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip |
|
53 |
+ DUP <emit-dec> |
|
54 |
+ INCr &>skip |
|
55 |
+ POP2 #000a DIV2 SWPr INCr STHkr ?&w |
|
56 |
+ POP2r POP2 POP2 JMP2r |
|
57 |
+ |
|
58 |
+@<print-dec-pad> ( byte -- ) |
|
59 |
+ #0a DIVk <emit-dec> |
|
60 |
+ DIVk MUL SUB |
|
61 |
+ ( >> ) |
|
62 |
+ |
|
63 |
+@<emit-dec> ( byte -- ) |
|
71 | 64 |
LIT "0 ADD #18 DEO |
72 |
- |
|
73 |
-JMP2r |
|
65 |
+ JMP2r |
|
74 | 66 |
|
75 | 67 |
( |
76 | 68 |
@|assets ) |
77 | 69 |
|
78 |
-@week-txt [ |
|
79 |
- "Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1 |
|
80 |
- "Sat $1 ] |
|
70 |
+@week-txt |
|
71 |
+ [ |
|
72 |
+ "Sun $1 "Mon $1 "Tue $1 "Wed $1 |
|
73 |
+ "Thu $1 "Fri $1 "Sat $1 ] |
|
81 | 74 |
|
82 |
-@month-txt [ |
|
83 |
- "Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1 |
|
84 |
- "Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1 ] |
|
75 |
+@month-txt |
|
76 |
+ [ |
|
77 |
+ "Jan $1 "Feb $1 "Mar $1 "Apr $1 |
|
78 |
+ "May $1 "Jun $1 "Jul $1 "Aug $1 |
|
79 |
+ "Sep $1 "Oct $1 "Nov $1 "Dec $1 ] |
|
85 | 80 |
|
86 |
-@dict |
|
81 |
+@dict ( ) |
|
87 | 82 |
&date "The 20 "date 20 "is: 20 $1 |
88 | 83 |
&time "The 20 "time 20 "is: 20 $1 |
89 | 84 |
&doty "The 20 "day 20 "of 20 "the 20 "year 20 "is: 20 $1 |