_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:DannyS712/12Hours.js

In this article, we will delve into the fascinating world of User:DannyS712/12Hours.js, exploring its various facets and its importance today. From its origins to its relevance in modern society, User:DannyS712/12Hours.js has played a fundamental role in various areas, impacting people's lives in different ways. Throughout these pages, we will examine its evolution over time, analyze its implications in different spheres of daily life, and reflect on its influence in today's world. Get ready to immerse yourself in a journey of discovery and learning about User:DannyS712/12Hours.js, and you will discover the relevance it has in our daily lives.
// Install with:
// <code><nowiki>		{{subst:Iusc|User:DannyS712/12Hours.js}}																	</nowiki></code>
// or with
// <code><nowiki>		importScript( 'User:DannyS712/12Hours.js' ); // Backlink: ] 					</nowiki></code> 
//
// Special thanks to User:Bility and their script, ], which I forked.
// If forking this script, please note my contributions / give me credit

var config = {
	name: ']',
	version: 2.3,
	debug: false
};

if (mw.config.get('wgAction') === 'history' || mw.config.get('wgCanonicalNamespace') === 'Special' || mw.config.get('wgAction') === 'view') {
	$(document).ready(function() {
		if (mw.config.get('wgAction')=='history') $('span.mw-history-histlinks ~ a').each(function() {
			if (($(this).attr("class") === "mw-changeslist-date") || $(this).attr("class") === "mw-changeslist-date userlink") convertTo12HourTime($(this));
			
		});
		else if (mw.config.get('wgCanonicalNamespace')=='Special') {
			if (mw.config.get('wgCanonicalSpecialPageName')=='Contributions'){
				if ($('div').hasClass('mw-warning-with-logexcerpt mw-content-ltr'))	do_log(true);
   				else $('ul').first().children().each(function() {convertTo12HourTime($(this).children().first());});
			}
			else if (mw.config.get('wgCanonicalSpecialPageName')=='Log') do_log(false);
			else if (mw.config.get('wgCanonicalSpecialPageName')=='Userrights') do_log(false);
		}
		else if (document.title.indexOf("Difference between revisions") > -1) do_dif();
		else if (window.location.href.indexOf("oldid") > -1) {
			convertTo12HourTime ( $('#mw-revision-date') );
		}
	});
}
function do_log ( second ){
	$('ul').first().children().each(function() {
		var html = $(this).html();
		if (config.debug) console.log( html );
		html = html.replace(/(\d\d:\d\d)/g, on_log);
		if (config.debug) console.log(html);
		$(this).html( html );
		//convertTo12HourTime_log($(this));
	});
	if (second){
		if (config.debug) console.log("blocked");
		$('ul').eq(1).children().each(function() {
			var html = $(this).html();
			if (config.debug) console.log( html );
			html = html.replace(/(\d\d:\d\d)/g, on_log);
			if (config.debug) console.log(html);
			$(this).html( html );
		});
	}
}
function on_log ( match, offset, string ){
	if (config.debug) console.log( match, convertTo12HourTime_log(match) );
	return convertTo12HourTime_log(match);
}
function on_diff ( rev_time_act ){
	var just_time = rev_time_act.substr(0, 5);
	var rev_time_rst = rev_time_act.substr(5);
	var new_time = convertFromTime(just_time);
	return ( new_time + rev_time_rst);
}
function convertTo12HourTime(timeElement) {
	var time = timeElement.html().substr(0,5);
	var converted = convertFromTime( time, true );
	timeElement.html(converted + timeElement.html().substr(5));
}
function convertTo12HourTime_log( time ) {
	var converted = convertFromTime( time, true );
	return converted;
}
function convertFromTime( time, space ){
	var hour = parseFloat(time.substr(0,2));
	if (hour<12) {
		hour = (hour===0) ? 12 : hour;
		time = (hour + time.substr(2,5) + ' am');
	} else {
		hour = (hour!=12) ? hour-12 : hour;
		time = (hour + time.substr(2,5) + ' pm');
	}
	if (hour<10) {
		if (space) time = (unescape('%A0%A0')+time);
	}
	return time;
}
function do_dif(){
	var rev_time_text = $("#mw-diff-ntitle1 > strong > a").text();
	var rev_time_pre;
	var rev_time_rest;
	if ( rev_time_text.substr(0, 15) === "Revision as of " ){
		rev_time_pre = "Revision as of ";
		rev_time_rest = rev_time_text.substr(15);
	} else if ( rev_time_text.substr(0, 22) === "Latest revision as of " ){
		rev_time_pre = "Latest revision as of ";
		rev_time_rest = rev_time_text.substr(22);
	}
	$("#mw-diff-ntitle1 > strong > a").text( rev_time_pre + on_diff(rev_time_rest));
	
	var rev_time_text2 = $("#mw-diff-otitle1 > strong > a").text();
	var rev_time_pre2;
	var rev_time_rest2;
	if ( rev_time_text2.substr(0, 15) === "Revision as of " ){
		rev_time_pre2 = "Revision as of ";
		rev_time_rest2 = rev_time_text2.substr(15);
	}
	$("#mw-diff-otitle1 > strong > a").text( rev_time_pre2 + on_diff(rev_time_rest2));
}