clock: update every second
If we don't update every second, we may show the wrong time for up to a minute on 1. resume; or 2. when changing the time; or 3. when changing the timezone. This is both annoying and and leads to people thinking that the tool for changing the time / timezone is broken. https://bugzilla.gnome.org/show_bug.cgi?id=635840 Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
9b55de1c6b
commit
4b2d6f8a99
@ -185,21 +185,6 @@ DateMenuButton.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let displayDate = new Date();
|
let displayDate = new Date();
|
||||||
let msecRemaining;
|
|
||||||
if (showSeconds) {
|
|
||||||
msecRemaining = 1000 - displayDate.getMilliseconds();
|
|
||||||
if (msecRemaining < 50) {
|
|
||||||
displayDate.setSeconds(displayDate.getSeconds() + 1);
|
|
||||||
msecRemaining += 1000;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
msecRemaining = 60000 - (1000 * displayDate.getSeconds() +
|
|
||||||
displayDate.getMilliseconds());
|
|
||||||
if (msecRemaining < 500) {
|
|
||||||
displayDate.setMinutes(displayDate.getMinutes() + 1);
|
|
||||||
msecRemaining += 60000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._clock.set_text(displayDate.toLocaleFormat(clockFormat));
|
this._clock.set_text(displayDate.toLocaleFormat(clockFormat));
|
||||||
|
|
||||||
@ -209,7 +194,7 @@ DateMenuButton.prototype = {
|
|||||||
dateFormat = _("%A %B %e, %Y");
|
dateFormat = _("%A %B %e, %Y");
|
||||||
this._date.set_text(displayDate.toLocaleFormat(dateFormat));
|
this._date.set_text(displayDate.toLocaleFormat(dateFormat));
|
||||||
|
|
||||||
Mainloop.timeout_add(msecRemaining, Lang.bind(this, this._updateClockAndDate));
|
Mainloop.timeout_add_seconds(1, Lang.bind(this, this._updateClockAndDate));
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user