Created
December 12, 2014 04:59
-
-
Save cssmagic/8d22e51b281ca41e2f8a to your computer and use it in GitHub Desktop.
GitHub Issue 显示标准化的时间格式
This file contains 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
$('div[id^=issuecomment-]').each(function () { | |
var $header = $(this).find('.timeline-comment-header-text') | |
var time = $header.find('time').attr('datetime') | |
var date = new Date(time) | |
var year = date.getFullYear() | |
var month = format(date.getMonth() + 1) | |
var day = format(date.getDate()) | |
var hour = format(date.getHours()) | |
var min = format(date.getMinutes()) | |
var sec = format(date.getSeconds()) | |
var fullTime = [year, month, day].join('-') + ' ' + [hour, min, sec].join(':') | |
// console.log(fullTime) | |
var author = $header.find('.author').html() | |
$header.html('@' + author + ' - ' + fullTime) | |
}) | |
function format(i) { | |
return i > 9 ? i : '0' + i | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment