Paste: calendar.swatch

Author: vegai
Mode: factor
Date: Sun, 31 May 2009 20:00:52
Plain Text |
USING: arrays math.vectors math.functions math.parser make accessors kernel math calendar macros ;

IN: calendar.swatch

CONSTANT: beats/day 1000

: beats/hour ( -- beats ) 
  beats/day 24 / ; 

: beats/minute ( -- beats )
  beats/hour 60 / ; 

: beats/second ( -- beats )
  beats/minute 60 / ; 

: beats-array ( -- array ) 
  [ beats/hour , beats/minute , beats/second , ] { } make ; 

: timestamp>swatch ( timestamp -- beats )
  [ hour>> beats/hour * ]
  [ minute>> beats/minute * ]
  [ second>> beats/second * ]
  tri + + beats/hour + 1000 mod ; 

: now-swatch ( -- beats )
  gmt timestamp>swatch ;

: now-swatch-str ( -- str )
  now-swatch round number>string ;

Annotation: swatch>...

Author: randy
Mode: factor
Date: Sat, 31 Oct 2009 17:45:21
Plain Text |
: swatch>gmt ( beats -- timestamp )
    beats/hour -
    1000 / 86400 * seconds [ gmt midnight ] dip time+ ;

: swatch>local-time ( beats -- timestamp )
    swatch>gmt >local-time ;  
    

New Annotation

Summary:
Author:
Mode:
Body: