Created
July 24, 2013 00:29
-
-
Save bentleyo/6067252 to your computer and use it in GitHub Desktop.
GitHub Output Local Commit Time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Output local time on GitHub Commit History | |
// @namespace http://bentleyo.com/ | |
// @version 0.25 | |
// @description Displays the local time next to GitHub commits instead of using PST | |
// @match https://github.com/*/commits* | |
// @copyright 2012+, Bentley O'Kane-Chasr | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// ==/UserScript== | |
jQuery('.commit-meta .js-relative-date').each(function() { | |
var d = new Date(jQuery(this).attr('datetime')); | |
var hours = d.getHours(); | |
var am = true; | |
if(hours > 12) { | |
am = false; | |
hours -= 12; | |
} else if(hours == 12) { | |
am = false; | |
} else if(hours === 0) { | |
hours = 12; | |
} | |
var minutes = '' + d.getMinutes(); | |
if(minutes.length < 2) { | |
minutes = '0' + minutes; | |
} | |
jQuery(this).closest('.authorship').append(jQuery('<strong class="local-time">' + hours + ':' + minutes + (am ? 'am' : 'pm') + '</strong>')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment