A JavaScript time-based data store.
var ClockBox = require("clockbox"),
date = new Date("1/26/2015"),
clockbox = new ClockBox("1/25/2015", "1/31/2015");
date.setHours(14);
clockbox.store(date, "data!");
console.log(clockbox.fetch("14:00 1/26/2015")); // "data!"
c = new ClockBox("1/25/2015", "1/31/2015");
The date
here (and for #fetch
, etc.) can be a Date instance or a string
which Date can parse.
var datestring = "1/26/2015 14:00";
c.store(datestring, "data!");
c.fetch(datestring); // => "data!"
This will return an Array-like object (the keys are Numbers) containing only the hours which hold data.
c.fetchDay(datestring)[14]; // => "data!"
This is the same as doing c.store(datestring, null)
.
c.clear(datestring);
c.fetch(datestring); // => null