3962c08662
FossilOrigin-Name: 9a36cf9d0e7ddd0131df3867aa4285f0c26ccde64ef7c193729932647d8829a3
46 lines
1.5 KiB
Forth
46 lines
1.5 KiB
Forth
# Time and Date
|
|
|
|
The `clock:` namespace contains words for interacting with the
|
|
system clock.
|
|
|
|
~~~
|
|
:clock:operation (:n-)
|
|
DEVICE:CLOCK io:scan-for
|
|
dup n:negative? [ drop 'Error:_clock_device_not_found s:put nl ] if;
|
|
io:invoke ;
|
|
|
|
:clock:timestamp (:-n) #0 clock:operation ;
|
|
:clock:day (:-n) #1 clock:operation ;
|
|
:clock:month (:-n) #2 clock:operation ;
|
|
:clock:year (:-n) #3 clock:operation ;
|
|
:clock:hour (:-n) #4 clock:operation ;
|
|
:clock:minute (:-n) #5 clock:operation ;
|
|
:clock:second (:-n) #6 clock:operation ;
|
|
:clock:utc:day (:-n) #7 clock:operation ;
|
|
:clock:utc:month (:-n) #8 clock:operation ;
|
|
:clock:utc:year (:-n) #9 clock:operation ;
|
|
:clock:utc:hour (:-n) #10 clock:operation ;
|
|
:clock:utc:minute (:-n) #11 clock:operation ;
|
|
:clock:utc:second (:-n) #12 clock:operation ;
|
|
~~~
|
|
|
|
## d:source
|
|
|
|
~~~
|
|
'interface/clock.retro s:dedup
|
|
dup 'clock:utc:second d:lookup d:source store
|
|
dup 'clock:utc:minute d:lookup d:source store
|
|
dup 'clock:utc:hour d:lookup d:source store
|
|
dup 'clock:utc:year d:lookup d:source store
|
|
dup 'clock:utc:month d:lookup d:source store
|
|
dup 'clock:utc:day d:lookup d:source store
|
|
dup 'clock:second d:lookup d:source store
|
|
dup 'clock:minute d:lookup d:source store
|
|
dup 'clock:hour d:lookup d:source store
|
|
dup 'clock:year d:lookup d:source store
|
|
dup 'clock:month d:lookup d:source store
|
|
dup 'clock:day d:lookup d:source store
|
|
dup 'clock:timestamp d:lookup d:source store
|
|
dup 'clock:operation d:lookup d:source store
|
|
drop
|
|
~~~
|