datetime device
This commit is contained in:
parent
9b79fae0be
commit
d2e771005e
|
@ -185,10 +185,42 @@ i invite you to compare these subroutines with the ones present in the 100r prog
|
|||
|
||||
=> https://git.sr.ht/~rabbits/nasu/tree/main/item/src/main.tal nasu source code
|
||||
|
||||
* the audio device
|
||||
* practice: small music instrument
|
||||
* datetime device: reading the date and time
|
||||
* practice: visualization of time
|
||||
# the datetime device
|
||||
|
||||
the datetime device can be useful for low resolution timing and/or for visualizations of time.
|
||||
|
||||
it has several fields that we can read, all of them based on the current system time and timezone:
|
||||
|
||||
```
|
||||
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
|
||||
```
|
||||
|
||||
* the year short corresponds to the number of year in the so called common era
|
||||
* the month byte counts the months since january (i.e. january is 0, february 1, and so on)
|
||||
* the day byte counts the days starting from 1
|
||||
* the hour, minute and second bytes correspond to what one would expect
|
||||
* dotw (day of the week) is a byte counts the days since sunday (i.e sunday is 0, monday is 1, and so on)
|
||||
* doty (day of the year) is a byte counts the days since january 1 (i.e. jan 1st is 0, jan 2nd is 1, and so on)
|
||||
* isdst (is daylight saving time) is a flag, 01 if it's daylight saving time and 00 if it's not.
|
||||
|
||||
it should be straightforward to use them! e.g. in order to read the hour of the day into the stack:
|
||||
|
||||
```
|
||||
.DateTime/hour DEI
|
||||
```
|
||||
|
||||
i invite you to develop a creative visualization of time!
|
||||
|
||||
maybe you can use these values as coordinates for some sprites, or maybe you can use them as sizes or limits for shapes created with loops.
|
||||
|
||||
or what about conditionally drawing sprites, and/or changing the system colors depending on the time? :)
|
||||
|
||||
remember that for timing with a little bit more resolution, you can count the times that the screen vector has been fired!
|
||||
|
||||
# the audio device
|
||||
|
||||
at last, the audio device!
|
||||
|
||||
|
||||
# support
|
||||
|
||||
|
|
Loading…
Reference in New Issue