time : (d,short) => { // Date to "4:15.28 pm" or "15:42"(short)
var h = d.getHours(), m = d.getMinutes()
if (short)
return (" "+h).substr(-2)+":"+("0"+m).substr(-2);
else {
var r = "am";
if (h==0) { h=12; }
else if (h>=12) {
if (h>12) h-=12;
r = "pm";
}
return (" "+h).substr(-2)+":"+("0"+m).substr(-2)+"."+("0"+d.getSeconds()).substr(-2)+" "+r;
}
},
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 was trying to extend BangleJS locale module to localize time and observed that time() function is not giving the expected result.
from this https://github.com/espruino/Espruino/blob/master/libs/js/banglejs/locale.js#L9 it looks like this is a bug.
and it should be