secret
Created

  • Download Gist
utc-to-local-time.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// ==UserScript==
// @name UTC to local time converter
// @namespace utc-to-local-time-converter
// @description Make times on chromium-status.appspot.com easier to read.
// @match http://chromium-status.appspot.com/*
// @match https://chromium-status.appspot.com/*
// @version 0.1
// ==/UserScript==
 
(function(document) {
var y = ', ' + new Date().getFullYear();
var j = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var m = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
[].forEach.call(document.querySelectorAll('table[border] td:nth-of-type(2)'), function (el, i) {
if (i == 0) {
el.width = 160;
} else {
var d, p = el.textContent.split(',');
p.splice(1, 0, y);
d = new Date(p.join(''));
el.textContent = j[d.getDay()] + ' ' + m[d.getMonth()] + ' ' +
(d.getDate() < 10 ? '0' : '') + d.getDate() + ', ' +
(d.getHours() > 12 ? (d.getHours() - 12 == 0 ? '12' : d.getHours() - 12) :
(d.getHours() == 0 ? '12' : d.getHours())) +
':' + (d.getMinutes() < 10 ? '0' : '') + d.getMinutes() + ' ' +
(d.getHours() > 12 ? 'p' : 'a') + 'm';
}
});
}(unsafeWindow.document));

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.