forth/chronograph.fs

34 lines
739 B
Forth
Executable File

\ chronograph.fs
\ Date and time conversion and arithmetic
What I want:
Enter: s" 2005-09-16 18:30:55" jst
Returns: corresponding Unix time (s?, ms?, double?, float?)
Enter: -> mdt
Displays: ISO time string corr. to TOS Unix time in given zone
Enter: s" 06:40:00" today
Returns: Unix time for given time on current date local zone
Enter: now
Returns: current Unix time
(if time kept in ms, use utime instead)
Leap year (Gregorian calendar): years divisible by 4 but not by 100 plus years divisible by 400
: leapyear? ( u -- f )
dup 4 mod
if drop false
else dup 100 mod
if drop true
else 400 mod
if false
else true
then
then
then ;