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

User:Ohconfucius/test/YMD dot dates.js

User:Ohconfucius/test/YMD dot dates.js is a topic that has captured the attention of many people in recent years. With its impact on society and culture, it has generated numerous debates and conflicting opinions. From its origins to the current moment, User:Ohconfucius/test/YMD dot dates.js has been the subject of study and research, and continues to be a point of interest for academics, experts and the general public. In this article we will explore different aspects related to User:Ohconfucius/test/YMD dot dates.js, analyzing its influence, its challenges and its opportunities.
// *********************************************************************************************

//This is a test (non-production) script, and may have untested errors. Please exercise due care should you decide to use it.

// *********************************************************************************************

// This script aligns dates in the format YYYY.MM.DD or YYYY/MM/DD into abbreviated dmy format allowed by ].

// Feedback and constructive criticism are welcome

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.orghttps://wiki386.com/en/TemplateScript
 * @update-token ]
 */
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');

importScript("User:Ohconfucius/script/MOSNUM_utils.js"); 
// <pre>

function ohc_dot_dates_to_dmy()
{
//ranges
	ohc_regex(/()@YYYY\/@MM\/@DD(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@YYYY\/@MM\/@DD(?=)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
	ohc_regex(/()@YYYY\.@MM\.@DD(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@YYYY\.@MM\.@DD(?=)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
	ohc_regex(/(\| ?)@YYYY\/@MM\/@DD(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@YYYY\/@MM\/@DD(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
	ohc_regex(/(\| ?)@YYYY\.@MM\.@DD(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@YYYY\.@MM\.@DD(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");

// resolvable ambiguous date formats
	ohc_regex(/()@YYYY\/@MM\/@DD(?=)/gi, '$1@Day @Mon @YYYY');
	ohc_regex(/()@YYYY\.@MM\.@DD(?=)/gi, '$1@Day @Mon @YYYY');
	ohc_regex(/()@DD@MM@YYNN(?=)/gi, '$1@Day @Mon @YYYY');
	ohc_regex(/(\| ?)@YYYY\/@MM\/@DD(?=\s*\|)/gi, '$1@Day @Mon @YYYY');
	ohc_regex(/(\| ?)@YYYY\.@MM\.@DD(?=\s*\|)/gi, '$1@Day @Mon @YYYY');
//	ohc_regex(/(\| ?)@DD@MM@YYNN(?=\s*\|)/gi, '$1@Day @Mon @YYYY');
}

/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION

var linkmap=;
function ohc_protect_dates()
{
	// protects dates within links, quotes, etc
	// the sensitive part is stored and replaced with a unique identifier,
	// which is later replaced with the stored part.
 
	var protect_function = function(s, begin, replace, end) {
		linkmap.push(replace);
		return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
	};
//\|x=
	regex(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function);
	regex(/(<math>)(*?)(<\/math>)/gi, protect_function);
	regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function);
	regex(/(<ref)(+)(>)/gi, protect_function);
	regex(/((?:Category|Image|File):)(]*)(])/gi, protect_function);
	regex(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function);
	regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function);
	regex(/(\{\{(?:harvnb|r|wikisource)\|)(+)(\})/gi, protect_function);
	regex(/(\]*)(\])/gi, protect_function);
	regex(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function);
//	regex(/(https?:|ftp:)(]*)(])/gi, protect_function);
	regex(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function);
	regex(/(<noinclude>)(*?)(<\/noinclude>)/gi, protect_function);
	regex(/(<gallery)(*?)(<\/gallery>)/gi, protect_function);
	regex(/(<poem>)(*?)(<\/poem>)/gi, protect_function);
	regex(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function);
	regex(/((?:image\d?|image_skyline|imagelocation\d?|imagename|imagefile|img|pic)\s*=)(*)()/gi, protect_function);
	regex(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function);
	regex(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function);
	regex(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function);
	regex(/(\s*(?:)\s*=)(\s*+\s*)(\|)/gi, protect_function);
	regex(/(\{\{navsource\|)(+)(\})/gi, protect_function);
	regex(/(\{\{(?:singlechart)\|)(+)(\})/gi, protect_function);
	regex(/(\{\{(?:defaultsort|graph):)(+)(\})/gi, protect_function);
	regex(/()(*)()/gi, protect_function);


	// works names
//	regex(/(.)(protect string)(.)/gi, protect_function);
	regex(/(.)(11\/22\/63)(.)/gi, protect_function);
	regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
	regex(/()(2\.13\.61)()/gi, protect_function);
//	regex(/(.)(4th of July, Asbury)(.)/gi, protect_function); //protected above globally

	
}


function ohc_unprotect_dates()
{

	//unprotect all dates
	regex(//g, '');
	regex(/⍌(+)⍍/g, function(x, n) {
		var res = linkmap;
		res = res.replace(/⍌(+)⍍/g, function(x, n) {
			var res = linkmap;
			res = res.replace(/⍌(+)⍍/g, function(x, n) {
				var res = linkmap;
				res = res.replace(/⍌(+)⍍/g, function(x, n) {
					return linkmap;
				});
				return res;
			});
			return res;
		});
		return res;
	});
}


function ohc_dot_edit_summary()
{
	//Add a tag to the summary box
	setoptions(minor='true');
	setreason('resolved ]', 'append');
	doaction('diff');
}

function ohc_dot_dates(){
// Add a tag to the summary box
 var txt=document.editform.wpTextbox1;
	ohc_protect_dates();
	ohc_dot_dates_to_dmy();
	ohc_unprotect_dates();
	ohc_dot_edit_summary();
}

$(function () {
 if(document.forms.editform) {
   mw.util.addPortletLink('p-tb', 'javascript:ohc_dot_dates()', 'DOT to dmy dates', 't-UK', 'UK-dot', '', '');

  }
});

// </pre>