User:Bility/convert24hourtime.js

if (mw.config.get('wgAction')=='history' || mw.config.get('wgCanonicalSpecialPageName')=='Contributions') { $(document).ready(function {	if (mw.config.get('wgAction')=='history') {		$('span.mw-history-histlinks ~ a').each(function { convertTo12HourTime($(this)); });	} else {		$('ul').first.children.each(function { convertTo12HourTime($(this).children.first); });	}; }); }; function convertTo12HourTime(timeElement) { var hour = parseFloat(timeElement.html.substr(0,2)); if (hour<12) { hour = (hour==0) ? 12 : hour; timeElement.html(hour + timeElement.html.substr(2,3) + ' am' + timeElement.html.substr(5)); } else { hour = (hour!=12) ? hour-12 : hour; timeElement.html(hour + timeElement.html.substr(2,3) + ' pm' + timeElement.html.substr(5)); };	if (hour<10) { timeElement.html(unescape('%A0%A0')+timeElement.html); }; };