Milestones and bindings
Control as many time-based and status-based events as you need.
W3Flints Clock-Timer allows you to implement some cool features with a few lines of code, calling some critical bindings and checking the milestone queue, if provided.
Milestones
Use milestones when you need to hook any behavior using an approximate time. Because of the relation between the step option and the accuracy level of any time object, W3Flints Clock-Timer cannot guarantee the puntual execution of a milestone, but it provides a second-to-second check, ensuring the execution of the milestone callback.
The milestone queue is a key-value object, in which the key is a datetime in ANSI format, and the value is a function which receives the device and the instant as parameters.
Helpers:
W3Flints Clock-Timer provides some helpers to create timestamps. Those are very useful to create keys fro the milestone stack and deadlines for timers.
- W3FCT.fn.dt.stamp(date): creates an ANSI representation for a Date object.
- W3FCT.fn.dt.stampFromOffset(offset): creates a Date object given an offset in seconds and the current time.
- W3FCT.fn.dt.fromANSI(ansi_string): converts an ANSI representation into a Date object.
Bindings
Bindings are a core-level and more accurate method to check the current time and clock status.
A full example
Let's create a timer with some milestones and bindings: