User:Zackmann08/convert24hourtime.js

// Adapted from 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.mw-changeslist-date').each(function { convertTo12HourTime($(this)); });	} else {		$('ul').first.children.each(function { convertTo12HourTime($(this).children.first); });	} }); }

if (mw.config.get('wgCanonicalSpecialPageName')=='Watchlist' ) { $(document).ready(function {	$('span.mw-changeslist-date').each(function { convertTo12HourTime($(this)); }); }); } function convertTo12HourTime(timeElement) { var hour = parseFloat(timeElement.html.substr(0,2)); // Next 2 lines are only for DST hour ++; if(hour===24){hour = 0;} 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); } }