whattimeisitrightmeow
whattimeisitrightmeow copied to clipboard
Please show seconds
😄
We could use javascript to get the seconds!1! :rofl: :man_facepalming: :nerd_face:
We don't want to trust the client, however, do we?
Oh boy
I have requested #13 as i found time.txt to be quite useful for ""resynchronising"" the clock periodically in its current format (while playing around, below), and this didn't seem to be intentional.
var time = document.getElementById("time").innerHTML;
var date = new Date();
date.setHours(time.substring(0,3));
date.setMinutes(time.substring(4,7));
date.setSeconds(00);
localStorage.setItem("now", date);
setInterval(updateClock, 1000);
function updateClock() {
if ( Math.floor(Math.random() * 60) != 0) {
var notNow = new Date(localStorage.now);
notNow.setSeconds(notNow.getSeconds() + 1);
// notNow is now now, as we have updated the seconds so that it is now now.
time.innerHTML = notNow;
localStorage.setItem("now",notNow);
} else {
// get the new now
fetch('http://smaslennikov.com/whattimeisitrightmeow/time.txt').then(function(response) {
return response.text();
}).then(function(text) {
var date = new Date();
date.setHours(text.substring(0,3));
date.setMinutes(text.substring(4,6));
date.setSeconds(00);
time.innerHTML = date;
localStorage.setItem("now",date);
});
}
}
edit: anyone got anything more creative?
+1 on this issue. This is a major blocker for me in using your code in production.