: hence ( duration -- timestamp ) now swap time+ ;
: ago ( duration -- timestamp ) now swap time- ;
+: nano-count>timestamp ( x -- timestamp )
+ nano-count - nanoseconds now time+ ;
+
: zeller-congruence ( year month day -- n )
#! Zeller Congruence
#! http://web.textfiles.com/computers/formulas.txt
{ [ dup 0 = ] [ now ((reset-timer)) ] }
{ [ run-queue deque-empty? not ] [ 1 - (reset-timer) ] }
{ [ sleep-queue heap-empty? ] [ 5 minutes hence ((reset-timer)) ] }
- [ sleep-queue heap-peek nip micros>timestamp ((reset-timer)) ]
+ [ sleep-queue heap-peek nip nano-count>timestamp ((reset-timer)) ]
} cond ;
: reset-timer ( timer -- )
SYMBOL: hand-last-button
SYMBOL: hand-last-time
0 hand-last-button set-global
-nano-count hand-last-time set-global
+0 hand-last-time set-global
SYMBOL: hand-buttons
V{ } clone hand-buttons set-global