Skip to content

Commit

Permalink
InternetTimeDesklet@stefan: Fix timezone (#909)
Browse files Browse the repository at this point in the history
Change the hour/minute/second variable assignments to explicitly be in UTC format. Also, add one hour to the "getUTCHours()" call, as the "Biel Mean Time" (BMT) which Beat Time is based upon, is defined by Swatch as UTC+1.

Previously this was calling Date's getHours/getMinutes/getSeconds functions, which returns LOCAL time. This had the effect of meaning the Beat time returned by this desklet was always incorrect unless your computer's time is set to the UTC+1 timezone.

This commit fixes that and ensures that the correct universal Beat Time will be displayed regardless of the user's timezone.
  • Loading branch information
christopher-conley committed Aug 15, 2023
1 parent 06f56a8 commit c9d48cf
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ NetBeatDesklet.prototype = {

refresh: function() {
let d = new Date();
let h = d.getHours();
let m = d.getMinutes();
let s = d.getSeconds();
let h = d.getUTCHours() + 1;
let m = d.getUTCMinutes();
let s = d.getUTCSeconds();
//let tzoff = 60 + d.getTimezoneOffset();
//let beats = ('000' + Math.floor((s + (m + tzoff) * 60 + h * 3600) / 86.4) % 1000).slice(-3);

Expand Down

0 comments on commit c9d48cf

Please sign in to comment.