Uhh
by MegaScience
JavaScript
function plural(s, i) {
return i + ' ' + (i > 1 ? s + 's' : s);
}
function sundayDelta(offset) {
// offset is in hours, so convert to miliseconds
offset = offset ? offset * 60 * 60 * 1000 : 0;
var now = new Date(new Date().getTime() + offset);
var days = 7 - now.getUTCDay() || 7;
var hours = 24 - now.getUTCHours();
var minutes = 60 - now.getUTCMinutes();
var seconds = 60 - now.getUTCSeconds();
return console.log([plural('day', days),
plural('hour', hours),
plural('minute', minutes),
plural('second', seconds)
].join(' '));
}
setInterval(() => sundayDelta(), 8000)