Skip to content

Commit

Permalink
Update checkup.js (sourcegraph#90)
Browse files Browse the repository at this point in the history
scripts: change the dateTimeString(ms) method

Currently there is a problem with the *Last check:* field if you are on a different timezone than GMT. The calculation way is wrong as you end up with a --<hours> causing the value to be NaN. Changed the function to return a UTC string date.

Fixes Last check field in the Status Page
  • Loading branch information
stefanoschrs authored and mholt committed May 2, 2019
1 parent 6d709e1 commit 8e9e67b
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions statuspage/js/checkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,7 @@ checkup.makeTimeTag = function(ms) {
// dateTimeString converts ms (in milliseconds) into
// a value usable in a <time> tag's datetime attribute.
function dateTimeString(ms) {
var d = new Date(ms);
return d.getFullYear()+"-"
+ checkup.leftpad(d.getMonth()+1, 2, "0")+"-"
+ checkup.leftpad(d.getDate(), 2, "0")+"T"
+ checkup.leftpad(d.getHours(), 2, "0")+":"
+ checkup.leftpad(d.getMinutes(), 2, "0")+":"
+ checkup.leftpad(d.getSeconds(), 2, "0")+"-"
+ checkup.leftpad((d.getTimezoneOffset()/60), 2, "0")+":00";
return (new Date(ms)).toUTCString();
}

return '<time class="dynamic" datetime="'+dateTimeString(ms)+'">'
Expand Down

0 comments on commit 8e9e67b

Please sign in to comment.