I've just made a modification, more like a dirty little hack, to use clock module.
var Clock = require("clock").Clock;
var clk=new Clock(14,6,4,0,0,0,0); // Y,M,D H:M:S IDK,IDK
var date;// = "5/6/14";
var json = {"6/3/14":"g","13/3/14":"b","20/3/14":"g","27/3/14":"b","3/4/14":"g","10/4/14":"b","17/4/14":"g","25/4/14":"b","1/5/14":"g","9/5/14":"b","15/5/14":"g","22/5/14":"b","30/5/14":"g","5/6/14":"b","12/6/14":"g","19/6/14":"b","26/6/14":"g","3/7/14":"b","10/7/14":"g","17/7/14":"b","24/7/14":"g","31/7/14":"b","7/8/14":"g","14/8/14":"b","21/8/14":"g","29/8/14":"b","4/9/14":"g","11/9/14":"b","18/9/14":"g","25/9/14":"b","1/10/14":"g","9/10/14":"b","16/10/14":"g","12/10/14":"b","30/10/14":"g","6/11/14":"b","13/11/14":"g","20/11/14":"b","27/11/14":"g","4/12/14":"b","11/12/14":"g","18/12/14":"b","24/12/14":"g","2/1/15":"s","8/1/15":"g","15/1/15":"b","22/1/15":"g","29/1/15":"b","5/2/15":"g","12/2/15":"b","19/2/15":"g","26/2/15":"b","5/3/15":"g","12/3/15":"b","19/3/15":"g","26/3/15":"b","2/4/15":"g","10/4/15":"b","16/4/15":"g","23/4/15":"b","30/4/15":"g","8/5/15":"b","14/5/15":"g","21/5/15":"b","29/5/15":"g","4/6/15":"b","11/6/15":"g","18/6/15":"b","25/6/15":"g","2/7/15":"b","9/7/15":"g","16/7/15":"b","23/7/15":"g","30/7/15":"b","6/8/15":"g","13/8/15":"b","20/8/15":"g","27/8/15":"b","4/9/15":"g","10/9/15":"b","17/9/15":"g","24/9/15":"b","1/10/15":"g","8/10/15":"b","15/10/15":"g","22/10/15":"b","29/10/15":"g"};
function check(){
var type;
if(!(date in json)){
console.log("Not a bin day");
}else{
switch(json[date]) {
case "g":
type = "Green bin";
break;
case "b":
type = "Brown bin";
break;
case "s":
type = "Green & Plastic";
break;
}
console.log("It's a bin day, its the " + type);
}
}
function update(){
var time = clk.getClockTime();
date = Math.floor(time.day + 1) + "/" + time.month + "/" + time.year;
check();
}
setWatch(function(){update();}, BTN1, {repeat:true,edge:"rising", debounce:5/*ms*/});
//setInterval(update,10000);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I've just made a modification, more like a dirty little hack, to use clock module.