From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.

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());

	};

};