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 ;