Skip to content

Instantly share code, notes, and snippets.

@danbeam
Created February 26, 2013 01:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save danbeam/545b33c9ff3140c3678b to your computer and use it in GitHub Desktop.
Save danbeam/545b33c9ff3140c3678b to your computer and use it in GitHub Desktop.
// ==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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment