Misplaced Pages

User:Ohconfucius/script/MOSNUM dates.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Ohconfucius | script Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 18:42, 26 June 2022 view sourceOhconfucius (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers328,947 editsm re-enable regex menu frameworkTag: Manual revert← Previous edit Revision as of 14:59, 28 June 2022 view source Ohconfucius (talk | contribs)Autopatrolled, Extended confirmed users, Pending changes reviewers328,947 edits migrate to templatescriptTag: RevertedNext edit →
Line 3: Line 3:


// Feedback and constructive criticism are welcome // Feedback and constructive criticism are welcome

// <pre>
$.when(
$.ajax("//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js", { dataType: "script", cache: true }),
$.ajax("//en.wikipedia.org/search/?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript", { dataType: "script", cache: true })
).then(function() {
pathoschild.TemplateScript.add(
[
{
name: "DATES to dmy",
tooltip: "Align all dates to dmy",
script: ohc_all_to_dmy_driver
},
{
name: "DATES to mdy",
tooltip: "Align all dates to mdy",
script: ohc_all_to_mdy_driver
},
/*{
name: "Expand ref dates",
tooltip: "Expand month names within refs",
script: ohc_expand_ref_dates_driver
},
{
name: "Expand all dates",
tooltip: "Expand month names throughout",
script: ohc_expand_all_dates_driver
},*/
{
name: "US-slash dates",
tooltip: "US-slash",
script: ohc_US_slash_dates_driver
},
{
name: "UK-slash dates",
tooltip: "UK-slash",
script: ohc_UK_slash_dates_driver
}
],

// common options
{ forActions: "edit", category: "MOSNUM Dates" }
);
});


/** /**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor. * Add custom extension methods to the TemplateScript editor.
* @see https://meta.wikimedia.org/TemplateScript * @param editor The TemplateScript editor to extend.
*/ */
function ohc_extend_editor(editor) {
// <pre>
editor.ohc_regex = function(rg, sub, func) {
if ($.inArray(mw.config.get('wgAction'), ) !== -1) {
var text = editor.get();
$.ajax(
text = ohc.dateutil.regex(text, rg, sub, func);
'//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js',
editor.set(text);
{dataType: 'script', cache: true}
).done(function () {
$.when(
mw.loader.using(),
$.ajax('//meta.wikimedia.org/search/?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript', { dataType: 'script', cache: true }), // temporary for 'regex' method
$.ajax('//en.wikipedia.org/search/?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript', { dataType: 'script', cache: true }),
$.ready
).done(function () {
var add = function() {
return mw.util.addPortletLink.apply(mw.util, arguments);
};


return editor;
$(add('p-tb', '#', 'DATES to dmy', 'dmy-unitfixer', 'Align all dates to dmy', '', '')).click(ohc_all_to_dmy_driver);
};
$(add('p-tb', '#', 'DATES to mdy', 'mdy-unitfixer', 'Align all dates to mdy', '', '')).click(ohc_all_to_mdy_driver);
// $(add('p-tb', '#', 'Expand ref dates', 't-expandref', 'Expand month names within refs', '', '')).click(ohc_expand_ref_dates_driver);
// $(add('p-tb', '#', 'Expand all dates', 't-expandall', 'Expand month names throughout', '', '')).click(ohc_expand_all_dates_driver);
$( add('p-tb', '#', 'US-slash dates', 't-US', 'US-slash', '', '') ).click(ohc_US_slash_dates_driver);
$( add('p-tb', '#', 'UK-slash dates', 't-UK', 'UK-slash', '', '') ).click(ohc_UK_slash_dates_driver);
});
});
} }


function ohc_fix_unambiguous_dates() function ohc_fix_unambiguous_dates(editor) {
editor
{
// resolvable ambiguous date formats // resolvable ambiguous date formats
// UK style // UK style
ohc_regex(/()@DD\.@MM\.@YYYY(?=)/gi, "$1@Day @Month @YYYY", function(d) { .ohc_regex(/()@DD\.@MM\.@YYYY(?=)/gi, "$1@Day @Month @YYYY", function(d) {
if (d.d == d.m) return true; if (d.d == d.m) return true;
if (d.d > 12) return true; if (d.d > 12) return true;
return false; return false;
}); })
ohc_regex(/()@DD\/@MM\/@YYYY(?=)/gi, "$1@Day @Month @YYYY", function(d) { .ohc_regex(/()@DD\/@MM\/@YYYY(?=)/gi, "$1@Day @Month @YYYY", function(d) {
if (d.d == d.m) return true; if (d.d == d.m) return true;
if (d.d > 12) return true; if (d.d > 12) return true;
return false; return false;
}); })


// US style // US style
ohc_regex(/()@MM\.@DD\.@YYYY(?=)/gi, "$1@Month @Day, @YYYY", function(d) { .ohc_regex(/()@MM\.@DD\.@YYYY(?=)/gi, "$1@Month @Day, @YYYY", function(d) {
if (d.d > 12) return true; if (d.d > 12) return true;
return false; return false;
}); })
ohc_regex(/()@MM\/@DD\/@YYYY(?=)/gi, "$1@Month @Day, @YYYY", function(d) { .ohc_regex(/()@MM\/@DD\/@YYYY(?=)/gi, "$1@Month @Day, @YYYY", function(d) {
if (d.d > 12) return true; if (d.d > 12) return true;
return false; return false;
}); });
} }


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


// resolvable ambiguous date formats // resolvable ambiguous date formats
ohc_regex(/()@MM\/@DD\/@YYNN(?=)/gi, '$1@Month @Day, @YYYY'); .ohc_regex(/()@MM\/@DD\/@YYNN(?=)/gi, "$1@Month @Day, @YYYY")
ohc_regex(/()@MM\.@DD\.@YYNN(?=)/gi, '$1@Month @Day, @YYYY'); .ohc_regex(/()@MM\.@DD\.@YYNN(?=)/gi, "$1@Month @Day, @YYYY")
ohc_regex(/()@MM@DD@YYNN(?=)/gi, '$1@Month @Day, @YYYY'); .ohc_regex(/()@MM@DD@YYNN(?=)/gi, "$1@Month @Day, @YYYY")
ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY'); .ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, "$1@Month @Day, @YYYY")
ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY'); .ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, "$1@Month @Day, @YYYY");
// ohc_regex(/(\| ?)@MM@DD@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY'); //.ohc_regex(/(\| ?)@MM@DD@YYNN(?=\s*\|)/gi, "$1@Month @Day, @YYYY");
} }
function ohc_UK_slash_dates_to_dmy()
{
//ranges
ohc_regex(/()@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/()@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");


function ohc_UK_slash_dates_to_dmy(editor) {
// resolvable ambiguous date formats
editor
ohc_regex(/()@DD\/@MM\/@YYNN(?=)/gi, '$1@Day @Month @YYYY');
// ranges
ohc_regex(/()@DD\.@MM\.@YYNN(?=)/gi, '$1@Day @Month @YYYY');
ohc_regex(/()@DD@MM@YYNN(?=)/gi, '$1@Day @Month @YYYY'); .ohc_regex(/()@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2")
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY'); .ohc_regex(/()@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2")
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY'); .ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2")
// ohc_regex(/(\| ?)@DD@MM@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY'); .ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:|&dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2")

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


function ohc_remove_leading_zeroes() function ohc_remove_leading_zeroes(editor) {
editor
{
ohc_regex(/(\D)@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear"); .ohc_regex(/(\D)@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear")
ohc_regex(/(\D)@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day"); .ohc_regex(/(\D)@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day")
ohc_regex(/(\D)@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear"); .ohc_regex(/(\D)@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear")
ohc_regex(/(\D)@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth"); .ohc_regex(/(\D)@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
} }


function ohc_delink_dates() function ohc_delink_dates(editor) {
editor
{
//add missing space between wikilinks // add missing space between wikilinks
regex(/(\]\])(\[\[)/gi, '$1 $2'); //remove (?!file:) to ensure a space between all links .replace(/(\]\])(\[\[)/gi, "$1 $2") // remove (?!file:) to ensure a space between all links
// rem redundant quote marks and parentheses
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'(]*)\'\'\'(?=\s*)/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'(]*)\'\'(?=\s*)/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"(]*)\"(?=\s*)/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\((]*)\)(?=\s*)/gi, "$1$2");


// rem redundant quote marks and parentheses
//delink unpiped dates
.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'(]*)\'\'\'(?=\s*)/gi, "$1$2")
//delink full dates
ohc_regex(/\(?:of)?@Month(?:\]\]\s?\\]/gi, "@Day @LMonth @YYYY"); .replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'(]*)\'\'(?=\s*)/gi, "$1$2")
.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"(]*)\"(?=\s*)/gi, "$1$2")
ohc_regex(/\\],? \\]/gi, "@LMonth @Day, @YYYY");
.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\((]*)\)(?=\s*)/gi, "$1$2")


//delink yyyy-mm-dd dates // delink unpiped dates
// delink full dates
ohc_regex(/\\]-\\]/gi, "@YYYY-@MM-@DD");
.ohc_regex(/\(?:of)?@Month(?:\]\]\s?\\]/gi, "@Day @LMonth @YYYY")
.ohc_regex(/\\],? \\]/gi, "@LMonth @Day, @YYYY")


//underscore and nbsp in linked dates // delink yyyy-mm-dd dates
ohc_regex(/\\]/gi, "@Day @LMonth"); .ohc_regex(/\\]-\\]/gi, "@YYYY-@MM-@DD")
ohc_regex(/\\]@th?/gi, "@LMonth @Day"); //consolidated regex with flexible removal of ordinal simple date .ohc_regex(/@YYYY-\\]/gi, "@YYYY-@MM-@DD")
ohc_regex(/\\]/gi, "@Day @LMonth");
ohc_regex(/\\]/gi, "@LMonth @YYYY");
ohc_regex(/\\]/gi, "@YYYY");
ohc_regex(/\\]/gi, "@MM-@DD");


//remove leading zero and links from linked date // underscore and nbsp in linked dates
ohc_regex(/\|&nbsp;)@ZD@th\]\]/gi, "@LMonth @Day"); .ohc_regex(/\\]/gi, "@Day @LMonth")
ohc_regex(/\|&nbsp;)@Month\]\]/gi, "@Day @LMonth"); .ohc_regex(/\\]@th?/gi, "@LMonth @Day") //consolidated regex with flexible removal of ordinal simple date
.ohc_regex(/\\]/gi, "@Day @LMonth")
.ohc_regex(/\\]/gi, "@LMonth @YYYY")
.ohc_regex(/\\]/gi, "@YYYY")


// remove nowrap template from dm and md dates // remove leading zero and links from linked date
ohc_regex(/(date*=*)\{\{(?:j|no ?(?:break|wrap))\|(?:@DD(?:|&nbsp;)@Month)( @yyyy|)\}\}/gi, '$1@DD @LMonth$2'); .ohc_regex(/\|&nbsp;)@ZD@th\]\]/gi, "@LMonth @Day")
ohc_regex(/(date*=*)\{\{(?:j|no ?(?:break|wrap))\|(?:@Month(?:|&nbsp;)@DD)( @yyyy|)\}\}/gi, '$1@LMonth @DD$2'); .ohc_regex(/\|&nbsp;)@Month\]\]/gi, "@Day @LMonth")
//delink single dm or 'dth the m'
ohc_regex(/(?:the\s)?\(?:of)?@Month\]\]/gi, "@Day @LMonth");
//delink single md or 'm the dth'
ohc_regex(/\(?:the)?@Day@th?\]\](?=\W)/gi, "@LMonth @Day");


// remove nowrap template from dm and md dates
//month+day piped
ohc_regex(/\(?:of)?@month|@month@dd@th?)\|((?:@month |)@day)@th?\]\]/gi, "$1"); .ohc_regex(/(date*=*)\{\{(?:j|no ?(?:break|wrap))\|(?:@DD(?:|&nbsp;)@Month)( @yyyy|)\}\}/gi, "$1@DD @LMonth$2")
ohc_regex(/\(?:of)?@month|@month@dd@th?)\|@Day@th?(@month|)\]\]/gi, "@Day $1"); .ohc_regex(/(date*=*)\{\{(?:j|no ?(?:break|wrap))\|(?:@Month(?:|&nbsp;)@DD)( @yyyy|)\}\}/gi, "$1@LMonth @DD$2")


// delink single dm or 'dth the m'
// ohc_regex(/\+|)\|(]+)@th?\]\]/gi, "$1");
// ohc_regex(/\+|)\|(]+)@th?\]\]/gi, "$1"); .ohc_regex(/(?:the\s)?\(?:of)?@Month\]\]/gi, "@Day @LMonth")
ohc_regex(/\+|)\|(]+)\]\]/gi, "$1");


// delink single md or 'm the dth'
//month+day+year pseudo-ISO dates
ohc_regex(/\\]-(?:\*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY"); .ohc_regex(/\(?:the)?@Day@th?\]\](?=\W)/gi, "@LMonth @Day")
ohc_regex(/\\]-(?:\*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");


//']Xyyyy ' to 'month day, year' // month+day piped
ohc_regex(/\\].@YYYY/gi, "@LMonth @Day, @YYYY"); .ohc_regex(/\(?:of)?@month|@month@dd@th?)\|((?:@month |)@day)@th?\]\]/gi, "$1")
.ohc_regex(/\(?:of)?@month|@month@dd@th?)\|@Day@th?(@month|)\]\]/gi, "@Day $1")
//']Xyyyy' to 'day month year'
ohc_regex(/\\].@YYYY/gi, "@Day @LMonth @YYYY"); //.ohc_regex(/\+|)\|(]+)@th?\]\]/gi, "$1")
//.ohc_regex(/\+|)\|(]+)@th?\]\]/gi, "$1")
.ohc_regex(/\+|)\|(]+)\]\]/gi, "$1")


// month+day+year pseudo-ISO dates
// century
.ohc_regex(/\\]-(?:\*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY")
regex(/\first)centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, '$1');
.ohc_regex(/\\]-(?:\*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY")
regex(/\first)centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|(]{1,30})\]\]/gi, '$1');
regex(/\d|th))(centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, '$1 $2$3');
ohc_regex(/\centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|(]{1,30})\]\]/gi, '$1');


//']Xyyyy ' to 'month day, year'
// months
ohc_regex(/\\]/gi, "@LMonth"); .ohc_regex(/\\].@YYYY/gi, "@LMonth @Day, @YYYY")
ohc_regex(/\]{1,30})\]\]/gi, "$1");


//']Xyyyy' to 'day month year'
// decades and years
.ohc_regex(/\\].@YYYY/gi, "@Day @LMonth @YYYY")
regex(/(\d{1,3}0)?s/g, '$1s');
regex(/\\]/g, '$1s');
regex(/\]{1,30})\]\]/g, '$1');
regex(/\\]/gi, '$1$2 $3');
regex(/\?)(AD|BC|CE|BCE)\]\]/gi, '$1$2');
regex(/\?)(\d{1,4})\]\]/gi, '$1$2$3');
ohc_regex(/()\\]/gi, '$1$2'); //piped year
regex(/\\d{3}|\d{0,2})\]\]/gi, '$1');
regex(/\]{1,30})\]\]/gi, '$1');
regex(/\]{1,30})\]\]/gi, '$1');


// century
//month+year
.replace(/\first)centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, "$1")
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
.replace(/\first)centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|(]{1,30})\]\]/gi, "$1")
ohc_regex(/\]+\|@Day @Month @YYYY\]\]/gi, "@Day @LMonth @YYYY");
ohc_regex(/\]+\|@Month @Day,? @YYYY\]\]/gi, "@LMonth @Day, @YYYY"); .replace(/\d|th))(centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, "$1 $2$3")
ohc_regex(/\]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2"); .ohc_regex(/\centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|(]{1,30})\]\]/gi, "$1")
ohc_regex(/\]+\|(@month|@yyyy)\]\]/gi, "$1");
ohc_regex(/\\]/gi, "$1");
ohc_regex(/\]{1,30})\]\]/gi, "$1");
ohc_regex(/\\](?= {2}^B)/gi, "@YYYY");


// months
ohc_regex(/(\]+\|@yyyy)(\]\])( season)/gi, "$1$3$2");
.ohc_regex(/\\]/gi, "@LMonth")
.ohc_regex(/\]{1,30})\]\]/gi, "$1")


// decades and years
//removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
.replace(/(\d{1,3}0)?s/g, "$1s")
// ohc_regex(/\\(\)]{1,32}\|@YYYY\]\]/gi, '@Year'); // 23/6/2021 – disabled delinking "other" year-in articles
.replace(/\\]/g, "$1s")
.replace(/\]{1,30})\]\]/g, "$1")
.replace(/\\]/gi, "$1$2 $3")
.replace(/\?)(AD|BC|CE|BCE)\]\]/gi, "$1$2")
.replace(/\?)(\d{1,4})\]\]/gi, "$1$2$3")
.ohc_regex(/()\\]/gi, "$1$2") // piped year
.replace(/\\d{3}|\d{0,2})\]\]/gi, "$1")
.replace(/\]{1,30})\]\]/gi, "$1")
.replace(/\]{1,30})\]\]/gi, "$1")


// month+year
//Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
// Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
ohc_regex(/\]+\|@Month\]\]/gi, "@LMonth");
ohc_regex(/\]{3,12}\|@Year\]\]/gi, '@Year'); .ohc_regex(/\]+\|@Day @Month @YYYY\]\]/gi, "@Day @LMonth @YYYY")
.ohc_regex(/\]+\|@Month @Day,? @YYYY\]\]/gi, "@LMonth @Day, @YYYY")
.ohc_regex(/\]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2")
.ohc_regex(/\]+\|(@month|@yyyy)\]\]/gi, "$1")
.ohc_regex(/\\]/gi, "$1")
.ohc_regex(/\]{1,30})\]\]/gi, "$1")
.ohc_regex(/\\](?= {2}^B)/gi, "@YYYY")


.ohc_regex(/(\]+\|@yyyy)(\]\])( season)/gi, "$1$3$2")
// month and day piped
ohc_regex(/\@day\|@MM-@DD\]\]/gi, "@MM-@DD");
ohc_regex(/\@day\|(]{1,30})\]\]/gi, "$1");
ohc_regex(/\|)?@month\|(]{1,30})\]\]/gi, "$1");


// removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
//years piped
//.ohc_regex(/\\(\)]{1,32}\|@YYYY\]\]/gi, "@Year"); // 23/6/2021 – disabled delinking "other" year-in articles
regex(/\]{1,30})\]\]/gi, '$1');

// Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
.ohc_regex(/\]+\|@Month\]\]/gi, "@LMonth")
.ohc_regex(/\]{3,12}\|@Year\]\]/gi, "@Year")

// month and day piped
.ohc_regex(/\@day\|@MM-@DD\]\]/gi, "@MM-@DD")
.ohc_regex(/\@day\|(]{1,30})\]\]/gi, "$1")
.ohc_regex(/\|)?@month\|(]{1,30})\]\]/gi, "$1")

// years piped
.replace(/\]{1,30})\]\]/gi, "$1");
} }


function ohc_fix_common_errors() function ohc_fix_common_errors(editor) {
editor
{
ohc_regex(/(\d)<sup>@th<\/sup>/gi, '$1th'); .ohc_regex(/(\d)<sup>@th<\/sup>/gi, "$1th")

// remove dashbot comment from dates
// remove dashbot comment from dates
regex(/<!-- ?DASHBot ?-->/gi, '');
ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=*)/gi, '$1c. $2'); //add space .replace(/<!-- ?DASHBot ?-->/gi, '')
.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=*)/gi, "$1c. $2") // add space

//common cs1 errors
// common cs1 errors
regex(/(\|\s*(?:date|year)\s*=)\s*(1\d|20)\?(?=*)/gi, '$1c. $20');
// regex(/(\|\s*(?:date|year)\s*=\s*(1)\d{2})(\d{2})(?=*)/gi, '$1–$2$3'); .replace(/(\|\s*(?:date|year)\s*=)\s*(1\d|20)\?(?=*)/gi, "$1c. $20")
// regex(/(\|\s*(?:date|year)\s*=\s*(20)\d)(\d)(?=*)/gi, '$1–$2$3'); .replace(/(\|\s*(?:date|year)\s*=\s*(1)\d{2})(\d{2})(?=*)/gi, "$1–$2$3")
ohc_regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*\s*@YYNN(?=*)/gi, '$1@YYYY1–@YYYY2'); //common cs1 error //.replace(/(\|\s*(?:date|year)\s*=\s*(20)\d)(\d)(?=*)/gi, "$1–$2$3")
regex(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1\d|20)\d)(?=*)/gi, '$1S$2 $3'); //common cs1 error .ohc_regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*\s*@YYNN(?=*)/gi, "$1@YYYY1–@YYYY2") // common cs1 error(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*\s*@YYYY(?=*)/gi, "$1@YYYY1–@YYYY2") //common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1\d|20)\d)(?=*)/gi, '$1A$2 $3'); //common cs1 error .replace(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1\d|20)\d)(?=*)/gi, "$1S$2 $3") // common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1\d|20)\d)(?=*)/gi, '$1F$2 $3'); //common cs1 error .replace(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1\d|20)\d)(?=*)/gi, "$1A$2 $3") // common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1\d|20)\d)(?=*)/gi, '$1W$2 $3'); //common cs1 error .replace(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1\d|20)\d)(?=*)/gi, "$1F$2 $3") // common cs1 error
regex(/(\|\s*(?:date)\s*=)\s*(Spring|Summer|Autumn|Fall|Winter)(S(?:pring|ummer)|Autumn|Fall|Winter),?\s*((?:1\d|20)\d)(?=*)/gi, '$1$2–$3 $4'); //common cs1 error .replace(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1\d|20)\d)(?=*)/gi, "$1W$2 $3") // common cs1 error
ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=*)/gi, '$11 $2'); //common cs1 error .replace(/(\|\s*(?:date)\s*=)\s*(Spring|Summer|Autumn|Fall|Winter)(S(?:pring|ummer)|Autumn|Fall|Winter) ?/gi, "$1$2–$3 ") // common cs1 error
.ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=*)/gi, "$11 $2") //common cs1 error
//.ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=*)/gi, "$1@Year") // common cs1 error
//.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=*)/gi, "$1c. @Year") // common cs1 error
//.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=*)/gi, "$1c. $2") // common cs1 error
.ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1\d{2}|2000)(?=*)/gi, "$1") // rem access date before Misplaced Pages (January 2001)
.ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1\d{2}|2000)(?=*)/gi, "$1") // rem access date before Misplaced Pages (January 2001)
.ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:April|June|September|November) @year)(?=*)/gi, "$130$2") // rem nonsense access date (short months)
.ohc_regex(/(\|\s*access-?date\s*=)\s*29( February (?:200|201))(?=*)/gi, "$128$2") // rem nonsense access date 29 Feb (non-leap year)
.ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3)( February @yyyy)(?=*)/gi, "$128$2") // rem nonsense access dates February
.replace(/(\|\s*access-?date\s*=)\s*(\d{4})(?=*)/gi, '') // common cs1 error

// month+day+year pseudo-ISO dates
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY")
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY")

.replace(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date)(?=*)/gi, "$1n.d.") // common cs1 error
.replace(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=*)/gi, "$1n.d.") // common cs1 error
.replace(/(\|\s*)year(\s*=\s*)(?=n\.?d\.)(?=*)/gi, "$1date$2") // common cs1 error

// remove parasitic metadata - days of the week/descriptives
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:*|)@Day\s+@Month\s+@YYYY((?:\b|)\s?)*(?=*)/gi, "$1@Day @Month @YYYY$2") // rem negate "<", "hyphens" "dashes" 26/6/2020
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)*@Month\s+@Day,\s+@YYYY((?:\b|)\s?)*(?=*)/gi, "$1@Month @Day, @YYYY$2") // rem negate "<", "hyphens" "dashes" 26/6/2020
//.ohc_regex(/(\|\s*date\s*=\s*)(?:*\D|)@Day\s+@Month\s+@YYYY ?– ?@Day\s+@Month\s+@YYYY*(?=*)/gi, "$1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year2")
//.ohc_regex(/(\|\s*date\s*=\s*)*@Month\s+@Day,\s+@YYYY ?– ?@Month @Day, @YYYY*(?=*)/gi, "$1@Mon1 @Day1, @Year1 – @@Mon2 Day2, @Year2")
//.replace(/(\|\s*author\s*=\s*)(?:posted|published)(?: by\b| on\b|)(?=\w)/gi, "$1")
//.replace(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=\s*)(?:accessed|retrieved|entered|posted|published|(?:last |)updated?|©)(?: by\b| on\b|)*(?=\w)/gi, "$1")
.replace(/(\|\s*(?:author|first|last)\s*=\s*)(?:by\b|on\b)*(?=\w)/gi, "$1")
.replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1")
.replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)?\s/gi, "$1") // rem "Sun" - false positives


// remove deprecated parameters (|day= and |month)
ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1\d{2}|2000)(?=*)/gi, '$1'); //rem access date before Misplaced Pages (January 2001)
ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1\d{2}|2000)(?=*)/gi, '$1'); //rem access date before Misplaced Pages (January 2001) .ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=)/gi, "$1date=@Day @Month @Year")
ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:April|June|September|November) @year)(?=*)/gi, '$130$2'); //rem nonsense access date (short months) .ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=)/gi, "$1date=@Month @Day, @Year")
ohc_regex(/(\|\s*access-?date\s*=)\s*29( February (?:200|201||202))(?=*)/gi, '$128$2'); //rem nonsense access date 29 Feb (non-leap year)
ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3)( February @yyyy)(?=*)/gi, '$128$2'); //rem nonsense access dates February
regex(/(\|\s*access-?date\s*=)\s*(\d{4})(?=*)/gi, ''); //common cs1 error
//month+day+year pseudo-ISO dates
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY");


// typos
regex(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date)(?=*)/gi, '$1n.d.'); //common cs1 error
.ohc_regex(/(date *= *)@Day @Month ?@th/gi, "$1@Day @Month")
regex(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=*)/gi, '$1n.d.'); //common cs1 error
.ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, "$1@Day @Month")
regex(/(\|\s*)year(\s*=\s*)(?=n\.?d\.)(?=*)/gi, '$1date$2'); //common cs1 error


.ohc_regex(/(date *= *(?:?\d|30|31) )(Jan|Febr)?{3,4}\w{0,2}(?= (?:1\d|20)\d\b)/gi, "$1$2uary")
// remove parasitic metadata - days of the week/descriptives
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:*|)@Day\s+@Month\s+@YYYY((?:\b|)\s?)*(?=*)/gi, "$1@Day @Month @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020 .ohc_regex(/(date *= *(?:?\d|30|31) )J{3,5}r\w{0,2}(?= (?:1\d|20)\d\b)/gi, "$1January")
.ohc_regex(/(date *= *(?:?\d) )Febua?r\w{0,2}(?= (?:1\d|20)\d\b)/gi, "$1February")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)*@Month\s+@Day,\s+@YYYY((?:\b|)\s?)*(?=*)/gi, "$1@Month @Day, @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
.ohc_regex(/(date *= *(?:?\d|30|31) )M\w{2,3}ch(?= (?:1\d|20)\d\b)/gi, "$1March")
.ohc_regex(/(date *= *(?:?\d|30) )A\w{2,3}l\w?(?= (?:1\d|20)\d\b)/gi, "$1April")
.ohc_regex(/(date *= *(?:?\d|30|31) )Ma(?= (?:1\d|20)\d\b)/gi, "$1May")
.ohc_regex(/(date *= *(?:?\d|30) )J\wn\w(?= (?:1\d|20)\d\b)/gi, "$1June")
.ohc_regex(/(date *= *(?:?\d|30) )J\w{1,2}e(?= (?:1\d|20)\d\b)/gi, "$1June")
.ohc_regex(/(date *= *(?:?\d|30|31) )Jul\w{1,2}(?= (?:1\d|20)\d\b)/gi, "$1July")
.ohc_regex(/(date *= *(?:?\d|30|31) )A{2,3}\w{1,4}t(?:\w|us)?(?= (?:1\d|20)\d\b)/gi, "$1August")
.ohc_regex(/(date *= *(?:?\d|30|31) )(Sept|Nov|Dec)\w{2,4}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, "$1$2ember")
.ohc_regex(/(date *= *(?:?\d|30) )S\w{0,2}p?\w{2,5}{2,3}\w?(?= (?:1\d|20)\d\b)/gi, "$1September")
.ohc_regex(/(date *= *(?:?\d|30|31) )O\w{0,2}t\w{1,3}{2,3}\w?(?= (?:1\d|20)\d\b)/gi, "$1October")
.ohc_regex(/(date *= *(?:?\d|30) )\w{1,2} ?\w{1,3}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, "$1November")
.ohc_regex(/(date *= *(?:?\d|30|31) )D? ?\w{1,4}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, "$1December")


.ohc_regex(/(date *= *)@Month\w(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1@Month") //rem stray digit at the end of year string
regex(/(\|\s*(?:author|first|last)\s*=\s*)(?:by\b|on\b)*(?=\w)/gi, "$1");
regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1");
regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)?\s/gi, "$1"); //<!-- rem "Sun" - false positives -->


.ohc_regex(/(date *= *)(Jan|Febr)?{3,4}\w{0,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1$2uary")
// remove deprecated parameters (|day= and |month)
ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=)/gi, '$1date=@Day @Month @Year'); .ohc_regex(/(date *= *)J{3,5}r\w{0,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1January")
ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=)/gi, '$1date=@Month @Day, @Year'); .ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:?\d),?|) (?:1\d|20)\d\b)/gi, "$1February")
.ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1March")
.ohc_regex(/(date *= *)A\w{2,3}l\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1April")
// typos
ohc_regex(/(date *= *)@Day @Month ?@th/gi, '$1@Day @Month'); .ohc_regex(/(date *= *)Ma(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1May")
ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, '$1@Day @Month'); .ohc_regex(/(date *= *)J\wn\w(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1June")
.ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1June")
.ohc_regex(/(date *= *)Jul\w{1,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1July")
.ohc_regex(/(date *= *)A{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1August")
.ohc_regex(/(date *= *)(Sept|Nov|Dec)\w{2,4}b{1,2}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1$2ember")
.ohc_regex(/(date *= *)S\w{0,2}p?\w{2,5}{2,3}\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1September")
.ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}{2,3}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1October")
.ohc_regex(/(date *= *)\w{1,2} ?\w{1,3}b{1,2}\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1November")
.ohc_regex(/(date *= *)D? ?\w{1,4}b{1,2}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1December")


// insert comma to separate date from army unit
ohc_regex(/(date *= *(?:?\d|30|31) )(Jan|Febr)?{3,4}\w{0,2}(?= (?:1\d|20)\d\b)/gi, '$1$2uary');
.ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1")
ohc_regex(/(date *= *(?:?\d|30|31) )J{3,5}r\w{0,2}(?= (?:1\d|20)\d\b)/gi, '$1January');
ohc_regex(/(date *= *(?:?\d) )Febua?r\w{0,2}(?= (?:1\d|20)\d\b)/gi, '$1February');
ohc_regex(/(date *= *(?:?\d|30|31) )M\w{2,3}ch(?= (?:1\d|20)\d\b)/gi, '$1March');
ohc_regex(/(date *= *(?:?\d|30) )A\w{2,3}l\w?(?= (?:1\d|20)\d\b)/gi, '$1April');
ohc_regex(/(date *= *(?:?\d|30|31) )Ma(?= (?:1\d|20)\d\b)/gi, '$1May');
ohc_regex(/(date *= *(?:?\d|30) )J\wn\w(?= (?:1\d|20)\d\b)/gi, '$1June');
ohc_regex(/(date *= *(?:?\d|30) )J\w{1,2}e(?= (?:1\d|20)\d\b)/gi, '$1June');
ohc_regex(/(date *= *(?:?\d|30|31) )Jul\w{1,2}(?= (?:1\d|20)\d\b)/gi, '$1July');
ohc_regex(/(date *= *(?:?\d|30|31) )A{2,3}\w{1,4}t(?:\w|us)?(?= (?:1\d|20)\d\b)/gi, '$1August');
ohc_regex(/(date *= *(?:?\d|30|31) )(Sept|Nov|Dec)\w{2,4}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, '$1$2ember');
ohc_regex(/(date *= *(?:?\d|30) )S\w{0,2}p?\w{2,5}{2,3}\w?(?= (?:1\d|20)\d\b)/gi, '$1September');
ohc_regex(/(date *= *(?:?\d|30|31) )O\w{0,2}t\w{1,3}{2,3}\w?(?= (?:1\d|20)\d\b)/gi, '$1October');
ohc_regex(/(date *= *(?:?\d|30) )\w{1,2} ?\w{1,3}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, '$1November');
ohc_regex(/(date *= *(?:?\d|30|31) )D? ?\w{1,4}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, '$1December');


// remove parasitic metadata - time
ohc_regex(/(date *= *)@Month\w(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1@Month'); //rem stray digit at the end of year string
.ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T\d:\d:\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|{1,2}T\s*|Z))(?=\s*)/g, "$1")
ohc_regex(/(date *= *)(Jan|Febr)?{3,4}\w{0,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1$2uary'); .ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
ohc_regex(/(date *= *)J{3,5}r\w{0,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1January'); .ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:?\d),?|) (?:1\d|20)\d\b)/gi, '$1February'); .ohc_regex(/(\|\s*\w*date\s*=\s*\w+@month @day,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1March'); .ohc_regex(/(\|\s*\w*date\s*=\s*\w+@day @month,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
ohc_regex(/(date *= *)A\w{2,3}l\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, '$1April'); .ohc_regex(/(\|\s*\w*date\s*=*)\s?(?:T?\d:\d:\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|{1,2}T\s*|Z))/g, "$1")
ohc_regex(/(date *= *)Ma(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1May');
ohc_regex(/(date *= *)J\wn\w(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, '$1June');
ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, '$1June');
ohc_regex(/(date *= *)Jul\w{1,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1July');
ohc_regex(/(date *= *)A{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1August');
ohc_regex(/(date *= *)(Sept|Nov|Dec)\w{2,4}b{1,2}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1$2ember');
ohc_regex(/(date *= *)S\w{0,2}p?\w{2,5}{2,3}\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, '$1September');
ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}{2,3}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1October');
ohc_regex(/(date *= *)\w{1,2} ?\w{1,3}b{1,2}\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, '$1November');
ohc_regex(/(date *= *)D? ?\w{1,4}b{1,2}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, '$1December');


// add back spaces or comma or remove other single artefact after date string
//insert comma to separate date from army unit
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Day\s{,2}@Month\s{,2}@YYYY?(?=\s*)/gi, "$1@Day @Month @YYYY$2")
ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1");
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month\s{,2}@Day,?\s{,2}@YYYY?(?=\s*)/gi, "$1@Month @Day, @YYYY$2")


// long-hand palliative for observed failure to insert spaces
// remove parasitic metadata - time
ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T\d:\d:\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|{1,2}T\s*|Z))(?=\s*)/g, "$1"); .ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)(?\d|30|31)\s*(January|February|March|April|May|June|July|August|September|October|November|December)\s*((?:19\d|20)\d\s?)*(?=\s*)/gi, "$1$2 $3 $4")
ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1"); //.ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Day\s*@Month\s*@YYYY(\s?|\s?)\w**(?=)/gi, "$1@Day @Month @YYYY$2")
ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1"); //.ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Month\s*@Day,\s*@YYYY(\s?|\s?)\w**(?=)/gi, "$1@Month @Day, @YYYY$2")
ohc_regex(/(\|\s*\w*date\s*=\s*\w+@month @day,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*\w+@day @month,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=*)\s?(?:T?\d:\d:\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|{1,2}T\s*|Z))/g, "$1");


// remove extraneous bracket //from Batty
// add back spaces or comma or remove other single artefact after date string
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Day\s{,2}@Month\s{,2}@YYYY?(?=\s*)/gi, "$1@Day @Month @YYYY$2"); .ohc_regex(/{{(\s*it(?:e|ation))(+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)(+)\](?=\s*)/gi, "{{$1$2$3$4")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month\s{,2}@Day,?\s{,2}@YYYY?(?=\s*)/gi, "$1@Month @Day, @YYYY$2");
//long-hand palliative for observed failure to insert spaces
ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)(?\d|30|31)\s*(January|February|March|April|May|June|July|August|September|October|November|December)\s*((?:19\d|20)\d\s?)*(?=\s*)/gi, "$1$2 $3 $4");
// ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Day\s*@Month\s*@YYYY(\s?|\s?)\w**(?=)/gi, "$1@Day @Month @YYYY$2");
// ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Month\s*@Day,\s*@YYYY(\s?|\s?)\w**(?=)/gi, "$1@Month @Day, @YYYY$2");


// fix bda template redirect
//remove extraneous bracket //from Batty
//.replace(/\{\{bda\|(+)\}\}/gi, "{{birth date and age|$1}}")
ohc_regex(/{{(\s*it(?:e|ation))(+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)(+)\](?=\s*)/gi, '{{$1$2$3$4');
//.replace(/\{\{dda\|(+)\}\}/gi, "{{death date and age|$1}}")


//zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}} // zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
// regex(/({{(?:end|start)date)\|df=y(?:es|)/gi, "$1"); //rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script //.replace(/({{(?:end|start)date)\|df=y(?:es|)/gi, "$1") // rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:*)}}/gi, "@Day @Month @YYYY"); .ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:*)}}/gi, "@Day @Month @YYYY")
regex(/{{#formatdate:(+)}}/gi, "$1"); .replace(/{{#formatdate:(+)}}/gi, "$1")
regex(/\{\{#dateformat:(+)(?:\|dmy|\|mdy)?\}\}/gi, '$1'); .replace(/\{\{#dateformat:(+)(?:\|dmy|\|mdy)?\}\}/gi, "$1")
// ohc_regex(/(date*=*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, '$1@Month @DD, @YYYY'); //stripping start/end template notes inside "|date=" parameter (line 72) //.ohc_regex(/(date*=*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, "$1@Month @DD, @YYYY") // stripping start/end template notes inside "|date=" parameter (line 72)
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:{3}|iso)|)}}/gi, "@Day @Month @YYYY"); .ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:{3}|iso)|)}}/gi, "@Day @Month @YYYY")
.ohc_regex(/\|\s*(?:archive|access|air)-?date\s*=\s*\{\{date\}\}(?=\s*)/gi, "") //remove {{date}} template without parameters that inappropriately return crrent date
ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@Day @Month @YYYY");
ohc_regex(/\{\{date\|(@DD@Mon|@Mon@DD)\}\}/gi, "@Day @Month"); .ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@YYYY-@MM-@DD")
.ohc_regex(/\{\{date\|@YYYY\/@MM\/@DD\}\}/gi, "@YYYY-@MM-@DD") //remove {{date}} template while rectifying slash dates within the template
regex(/\{\{date\|(+)(?:\|l?(?:{3}|iso|none|link))?\}\}/gi, '$1');
ohc_regex(/*\{\{accessdate\|@YYYY-@MM-@DD*\}\}/gi, " Retrieved @YYYY-@MM-@DD"); .ohc_regex(/\{\{date\|(@DD@Mon|@Mon@DD)\}\}/gi, "@Day @Month")
ohc_regex(/*\{\{retrieved*\|accessdate=(*)\}\}/gi, " Retrieved $1"); .replace(/\{\{date\|(+)(?:\|l?(?:{3}|iso|none|link))?\}\}/gi, "$1")
.ohc_regex(/*\{\{accessdate\|@YYYY-@MM-@DD*\}\}/gi, " Retrieved @YYYY-@MM-@DD")
// ohc_regex(/(date*=*|\w{2,}*)\{\{(?:start|end).date*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, '$1@YYYY'); //stripping start/end template (disabling to placate Pigsonthewing)
// ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, '@Month @YYYY') //stripping start/end template notes .ohc_regex(/*\{\{retrieved*\|accessdate=(*)\}\}/gi, " Retrieved $1")
// ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, ''); //stripping start/end template notes //.ohc_regex(/(date*=*|\w{2,}*)\{\{(?:start|end).date*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, "$1@YYYY") // stripping start/end template (disabling to placate Pigsonthewing)
ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month") //.ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, "@Month @YYYY") // tripping start/end template notes
//.ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, '') // stripping start/end template notes
.ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")


//expand one and two-digit years in ranges // expand one and two-digit years in ranges
regex(/(\()@Month @YYYY@Month @YYNN(\))/gi, '$1@Month1 @YYYY1 – @Month2 @YYYY2$2'); .replace(/(\()@Month @YYYY@Month @YYNN(\))/gi, "$1@Month1 @YYYY1 – @Month2 @YYYY2$2")
regex(/(\(1)(\d)(1)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(1)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(2)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(2)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(3)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(3)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(4)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(4)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(5)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(5)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(6)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(6)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(7)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(7)(\))/gi, "$1$2$3–$2$4")
regex(/(\(1)(\d)(8)(9\))/gi, '$1$2$3–$2$4'); .replace(/(\(1)(\d)(8)(9\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(1)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(1)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(2)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(2)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(3)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(3)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(4)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(4)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(5)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(5)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(6)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(6)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(7)(\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(7)(\))/gi, "$1$2$3–$2$4")
regex(/(\(20)()(8)(9\))/gi, '$1$2$3–$2$4'); .replace(/(\(20)()(8)(9\))/gi, "$1$2$3–$2$4")


ohc_regex(/(\W)@DD@th?, @DD@th?((?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;))@DD@th?(?:\sof\s?)?(|&nbsp;)@Month(?=\W)/gi, '$1@Day1, @Day2$2@Day3$3@LMonth'); .ohc_regex(/(\W)@DD@th?, @DD@th?((?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;))@DD@th?(?:\sof\s?)?(|&nbsp;)@Month(?=\W)/gi, "$1@Day1, @Day2$2@Day3$3@LMonth")
ohc_regex(/(\W)@DD@th?((?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;))@DD@th?(?:\sof\s?|)(|&nbsp;)@Month(?=\W)/gi, '$1@Day1$2@Day2$3@LMonth'); .ohc_regex(/(\W)@DD@th?((?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;))@DD@th?(?:\sof\s?|)(|&nbsp;)@Month(?=\W)/gi, "$1@Day1$2@Day2$3@LMonth")
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, '$1@Day @LMonth @YYYY'); .ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, "$1@Day @LMonth @YYYY")
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, '$1@Day @LMonth'); .ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, "$1@Day @LMonth")
ohc_regex(/(\W)@Day@th?(?:\sof|)(|&nbsp;|{{(?:break|nbsp)}})@Month(?=\w])/gi, '$1@Day$2@LMonth'); .ohc_regex(/(\W)@Day@th?(?:\sof|)(|&nbsp;|{{(?:break|nbsp)}})@Month(?=\w])/gi, "$1@Day$2@LMonth")
ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: |&nbsp;)@DD@th?(\s(?:and|&|to|or)(?:|&nbsp;))(?:the\s)?@DD@th?(?=\w])/gi, '$1@LMonth @Day1, @Day2$2@Day3'); .ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: |&nbsp;)@DD@th?(\s(?:and|&|to|or)(?:|&nbsp;))(?:the\s)?@DD@th?(?=\w])/gi, "$1@LMonth @Day1, @Day2$2@Day3")
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:|&nbsp;)|\sof\s)?(\d{3,4}\W\D)/gi, '$1$2 $3$4$5@Day, $6'); .ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:|&nbsp;)|\sof\s)?(\d{3,4}\W\D)/gi, "$1$2 $3$4$5@Day, $6")
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, '$1$2 $3$4$5@Day'); .ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, "$1$2 $3$4$5@Day")
ohc_regex(/(\W)@Month(|&nbsp;|{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, '$1@LMonth$2@Day, @Year'); .ohc_regex(/(\W)@Month(|&nbsp;|{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, "$1@LMonth$2@Day, @Year")
ohc_regex(/(\W)@Month @Day(?:\sof|,|)(|&nbsp;|{{(?:break|nbsp)}})@Year(?=\w])/gi, '$1@Month @Day,$2@Year'); .ohc_regex(/(\W)@Month @Day(?:\sof|,|)(|&nbsp;|{{(?:break|nbsp)}})@Year(?=\w])/gi, "$1@Month @Day,$2@Year")


// consolidating/amalgamating date fields // consolidating/amalgamating date fields
ohc_regex(/(\|*date*=*@day)\s*\|*month=*(@month)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2 $3"); .ohc_regex(/(\|*date*=*@day)\s*\|*month=*(@month)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2 $3")
ohc_regex(/(\|*date*=*@day.?@month)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2"); .ohc_regex(/(\|*date*=*@day.?@month)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2")
ohc_regex(/(\|*date*=*@month.?@day)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2"); .ohc_regex(/(\|*date*=*@month.?@day)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2")


// eliminating dates and time placed in author parameter // eliminating dates and time placed in author parameter
//removing artefacts from Indian news sites (TNN Aug 30, 2012, 05.46AM) // removing artefacts from Indian news sites (TNN Aug 30, 2012, 05.46AM)
ohc_regex(/(\|\s*author\s*=\s*(?:{2,3}\b))(?:*)\d{4}, {4,5}(&nbsp;|)M IST(?=*\|)/g, '$1$2'); .ohc_regex(/(\|\s*author\s*=\s*(?:{2,3}\b))(?:*)\d{4}, {4,5}(&nbsp;|)M IST(?=*\|)/g, "$1$2")
// ohc_regex(/(\|\s*author=(?:|{}]*))(TNN|PTI) @day @month @yyyy, {4,5}(&nbsp;|)M IST(?=*\|)/g, '$1$2'); //.ohc_regex(/(\|\s*author=(?:|{}]*))(TNN|PTI) @day @month @yyyy, {4,5}(&nbsp;|)M IST(?=*\|)/g, "$1$2")


ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|)|)(?=\|)/g, "$1"); .ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|)|)(?=\|)/g, "$1")
ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|)|)(?=\|)/g, "$1"); .ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|)|)(?=\|)/g, "$1")
ohc_regex(/(\|\s*author\s*=\s*\w+)@month @day,? @yyyy(?:|{}]*)(?=)/g, "$1"); .ohc_regex(/(\|\s*author\s*=\s*\w+)@month @day,? @yyyy(?:|{}]*)(?=)/g, "$1")
ohc_regex(/(\|\s*author\s*=\s*\w+)@day @month,? @yyyy(?:|{}]*)(?=)/g, "$1"); .ohc_regex(/(\|\s*author\s*=\s*\w+)@day @month,? @yyyy(?:|{}]*)(?=)/g, "$1")
ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)@dd-@mm-@yyyy/gi, "$1"); .ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)@dd-@mm-@yyyy/gi, "$1")
ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)@YYYY-@MM-@DD ?/gi, "$1"); .ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)@YYYY-@MM-@DD ?/gi, "$1")
regex(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w+)?)\d:\d(?:|&nbsp;)?(?:m|\.m\.|)(?: ?(?:{1,2}T|UTC)?|)/gi, "$1"); .replace(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w+)?)\d:\d(?:|&nbsp;)?(?:m|\.m\.|)(?: ?(?:{1,2}T|UTC)?|)/gi, "$1")
// ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)\s*\d\d(?:\d|)/gi, "$1"); //let's see later if we need this //.ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)\s*\d\d(?:\d|)/gi, "$1") //let's see later if we need this


// eliminating mm-dd-yyyy dates // eliminating mm-dd-yyyy dates
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM(1|2\d|3)@YYYY/gi, "$1@Month $2, @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM(1|2\d|3)@YYYY/gi, "$1@Month $2, @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Mon(1|2\d|3)@YYYY/gi, "$1@Month $2, @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Mon(1|2\d|3)@YYYY/gi, "$1@Month $2, @YYYY")
ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@MM(1|2\d|3)@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY"); .ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@MM(1|2\d|3)@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY")
// ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY"); //.ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY")


ohc_regex(/()@Mon(1|2\d|3)@YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@Mon(1|2\d|3)@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@Mon\/(1|2\d|3)\/@YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@Mon\/(1|2\d|3)\/@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@Mon\.(1|2\d|3)\.@YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@Mon\.(1|2\d|3)\.@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@Mon (1|2\d|3) @YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@Mon (1|2\d|3) @YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@MM(1|2\d|3)@YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@MM(1|2\d|3)@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@MM\/(1|2\d|3)\/@YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@MM\/(1|2\d|3)\/@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@MM\.(1|2\d|3)\.@YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@MM\.(1|2\d|3)\.@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
ohc_regex(/()@MM (1|2\d|3) @YYYY(?=)/gi, "$1@Mon $2, @YYYY"); .ohc_regex(/()@MM (1|2\d|3) @YYYY(?=)/gi, "$1@Mon $2, @YYYY")


// eliminating dd-mm-yyyy dates (assumed default) // eliminating dd-mm-yyyy dates (assumed default)
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@MM@YYYY/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@MM@YYYY/gi, "$1@Day @Month @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@Mon@YYYY/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@Mon@YYYY/gi, "$1@Day @Month @YYYY")
ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@DD@MM@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY"); .ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@DD@MM@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY")
ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY"); .ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY")
ohc_regex(/()@DD@Mon@YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD@Mon@YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD\/@Mon\/@YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD\/@Mon\/@YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD\.@Mon\.@YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD\.@Mon\.@YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD @Mon @YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD @Mon @YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD@MM@YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD@MM@YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD\/@MM\/@YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD\/@MM\/@YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD\.@MM\.@YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD\.@MM\.@YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/()@DD @MM @YYYY(?=)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/()@DD @MM @YYYY(?=)/gi, "$1@Day @Month @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@Month@YYNN(?=\s*)/gi, '$1@Day @Month @YYYY'); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@Month@YYNN(?=\s*)/gi, "$1@Day @Month @YYYY")


//convert yyyy-dd-mm to yyyy-mm-dd //convert yyyy-dd-mm to yyyy-mm-dd
ohc_regex(/{{(\s*it(?:e|ation))(+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1|20)\d{2})(1|2\d|3)(0?\d|1)(\s*)/gi, '{{$1$2$3-$5-$4$6'); //from Batty .ohc_regex(/{{(\s*it(?:e|ation))(+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1|20)\d{2})(1|2\d|3)(0?\d|1)(\s*)/gi, "{{$1$2$3-$5-$4$6") // from Batty


// eliminating other errant formats // eliminating other errant formats
ohc_regex(/(\|(?:*)date\s*=\s*)(?\d|30|31) @Month \2,? @YYYY(?=\s*)/gi, "$1$2 @Month @YYYY"); //repeated digits .ohc_regex(/(\|(?:*)date\s*=\s*)(?\d|30|31) @Month \2,? @YYYY(?=\s*)/gi, "$1$2 @Month @YYYY") //repeated digits
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day ?@Month ?200(\d)?(?=\s*)/gi, "$1@Day @Month 20$2"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day ?@Month ?200(\d)?(?=\s*)/gi, "$1@Day @Month 20$2")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month ?@Day,? ?200(\d)?(?=\s*)/gi, "$1@Month @Day, 20$2"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month ?@Day,? ?200(\d)?(?=\s*)/gi, "$1@Month @Day, 20$2")


ohc_regex(/(\()@DD-@MM-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2'); .ohc_regex(/(\()@DD-@MM-@YYYY(\)\W)/gi, "$1@Day @Month @YYYY$2")
ohc_regex(/(\()@DD-@Month-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2'); .ohc_regex(/(\()@DD-@Month-@YYYY(\)\W)/gi, "$1@Day @Month @YYYY$2")
ohc_regex(/(\|(?:*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|(?:*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*)/gi, "$1@Day @Month @YYYY")
ohc_regex(/(\|(?:*)date\s*=\s*)@DD @Month,? @YYYY(?=\s*)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|(?:*)date\s*=\s*)@DD @Month,? @YYYY(?=\s*)/gi, "$1@Day @Month @YYYY")
ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*)/gi, "$1@Day @Month @YYYY")
ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*)/gi, "$1@Day @Month @YYYY")
ohc_regex(/\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)"); .ohc_regex(/\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)")
ohc_regex(/\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)"); .ohc_regex(/\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)")
ohc_regex(/\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)"); .ohc_regex(/\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)")
ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @Month(?=\s*)/gi, "$1@Month @YYYY"); .ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @Month(?=\s*)/gi, "$1@Month @YYYY")
ohc_regex(/\(@YYYY, @Month\)/gi, " (@Month @YYYY)"); .ohc_regex(/\(@YYYY, @Month\)/gi, " (@Month @YYYY)")
ohc_regex(/\(@Mon@YYYY\)/gi, " (@Mon @YYYY)"); .ohc_regex(/\(@Mon@YYYY\)/gi, " (@Mon @YYYY)")


//CS1 errors ISO-like dates (too few or too many digits) // CS1 errors ISO-like dates (too few or too many digits)
ohc_regex(/(date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes .ohc_regex(/(date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@YYYY-@ZM-@ZD") //ndashes and emdashes
ohc_regex(/(\|\s*access-?date\s*=)\s*@YYYY-0@DD(?=\s*)/gi, ""); //rem nonsense access date .ohc_regex(/(\|\s*access-?date\s*=)\s*@YYYY-0@DD(?=\s*)/gi, "") //rem nonsense access date
ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY@MM@DD(?=\s*)/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes .ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY@MM@DD(?=\s*)/gi, "$1@YYYY-@ZM-@ZD") //ndashes and emdashes
// ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY@MM(?=\s*)/gi, "$1@Month @YYYY"); //transform "yyyy-mm" to "month year" //.ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY@MM(?=\s*)/gi, "$1@Month @YYYY") //transform "yyyy-mm" to "month year"
ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3"); .ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3")
ohc_regex(/(<ref*>+?)()@YYYY@MM()(*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4"); .ohc_regex(/(<ref*>+?)()@YYYY@MM()(*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4")


// spaces and commas between month and year // spaces and commas between month and year
ohc_regex(/@Month(?:,?|\s+of|)(\s|&nbsp;)@YYYY(?=\D)/gi, "@LMonth$1@YYYY"); .ohc_regex(/@Month(?:,?|\s+of|)(\s|&nbsp;)@YYYY(?=\D)/gi, "@LMonth$1@YYYY")


// fix month names (capitalize, remove dots) // fix month names (capitalize, remove dots)
ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2"); .ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2")
ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2"); .ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2")
ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2"); .ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2")
ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2"); .ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2")
regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=*(=|BC|AD|CE))/g, '$1c$2'); .replace(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=*(=|BC|AD|CE))/g, "$1c$2")
// regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?!\w*|''|")/g, '$1c$2'); //.replace(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?!\w*|''|")/g, "$1c$2")


//spaces and commas - in date formats //spaces and commas - in date formats
ohc_regex(/(\D\W\+(@month)(\]\])?*,*(\?\]?\W\D)/gi, "$1 $2$3 $4"); .ohc_regex(/(\D\W\+(@month)(\]\])?*,*(\?\]?\W\D)/gi, "$1 $2$3 $4")
ohc_regex(/(\D\W\+(@dd)(\]?\]?)(?:*,*)(\?\]?\W\D)/gi, "$1$2 $3$4, $5"); .ohc_regex(/(\D\W\+(@dd)(\]?\]?)(?:*,*)(\?\]?\W\D)/gi, "$1$2 $3$4, $5")
ohc_regex(/(\D\W\+(@dd)(\]?\]?)+(\?\]?\W\D)/gi, "$1$2 $3$4, $5"); .ohc_regex(/(\D\W\+(@dd)(\]?\]?)+(\?\]?\W\D)/gi, "$1$2 $3$4, $5")


ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2"); //repeat after delinking .ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2") //repeat after delinking


// spaces and commas - md-md and dm-dm date ranges // spaces and commas - md-md and dm-dm date ranges
ohc_regex(/(\D\W)@Month\s@DD(&nbsp;|\s)(?:|&dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2"); .ohc_regex(/(\D\W)@Month\s@DD(&nbsp;|\s)(?:|&dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2")
ohc_regex(/(\D\W)@Month\s@DD(?:|&dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2"); .ohc_regex(/(\D\W)@Month\s@DD(?:|&dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2")
ohc_regex(/(\D\W)@DD\s@Month(&nbsp;|\s)(?:|&dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2"); .ohc_regex(/(\D\W)@DD\s@Month(&nbsp;|\s)(?:|&dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2")
ohc_regex(/(\D\W)@DD\s@Month(?:|&dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2"); .ohc_regex(/(\D\W)@DD\s@Month(?:|&dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2")


// spaces and commas - d-dm and md-d date ranges // spaces and commas - d-dm and md-d date ranges
ohc_regex(/(\D\W)@Month(\s|&nbsp;)@DD@th?(?:(?:\s*|&nbsp;|)(?:\s*|&nbsp;|))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2"); .ohc_regex(/(\D\W)@Month(\s|&nbsp;)@DD@th?(?:(?:\s*|&nbsp;|)(?:\s*|&nbsp;|))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2")
ohc_regex(/(\D\W)@DD@th?(?:(?:\s*|&nbsp;|)(?:\s*|&nbsp;|))@DD@th?(\s|&nbsp;)@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1"); .ohc_regex(/(\D\W)@DD@th?(?:(?:\s*|&nbsp;|)(?:\s*|&nbsp;|))@DD@th?(\s|&nbsp;)@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1")


// spaces and commas between month and year (again) // spaces and commas between month and year (again)
ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1"); .ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
} }


Line 474: Line 517:
/// ISO to long format /// ISO to long format


function ohc_ISO_to_dmy_in_citations() function ohc_ISO_to_dmy_in_citations(editor) {
editor
{
//ISO dates within single citation // ISO dates within single citation
ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //regex which converts ymd to dmy or mdy throughout (within citation templates) .ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
} }


function ohc_ISO_to_mdy_in_citations() function ohc_ISO_to_mdy_in_citations(editor) {
editor
{
//ISO dates within single citation // ISO dates within single citation
ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY"); //regex which converts ymd to dmy or mdy throughout (within citation templates) .ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");
ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");
} }


function ohc_ISO_to_dmy_in_references() function ohc_ISO_to_dmy_in_references(editor) {
editor
{
//multiple calls for multiple dates within single citation // multiple calls for multiple dates within single citation
ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3"); .ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3")
ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3"); .ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
} }


function ohc_ISO_to_mdy_in_references() function ohc_ISO_to_mdy_in_references(editor) {
editor
{
//multiple calls for multiple dates within single citation // multiple calls for multiple dates within single citation
ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3"); .ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3")
ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3"); .ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
} }


// currently unused // currently unused
function ohc_ISO_to_dmy_anywhere() function ohc_ISO_to_dmy_anywhere(editor) {
editor
{
//multiple calls for multiple dates within single citation // multiple calls for multiple dates within single citation
ohc_regex(/()@YYYY@MM@DD()/gi, '$1@Day @Month @YYYY$2'); .ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Day @Month @YYYY$2")
ohc_regex(/()@YYYY@MM@DD()/gi, '$1@Day @Month @YYYY$2'); .ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Day @Month @YYYY$2")
ohc_regex(/()@YYYY@MM@DD()/gi, '$1@Day @Month @YYYY$2'); .ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Day @Month @YYYY$2");
} }


// currently unused // currently unused
function ohc_ISO_to_mdy_anywhere() function ohc_ISO_to_mdy_anywhere(editor) {
editor
{
//multiple calls for multiple dates within single citation // multiple calls for multiple dates within single citation
ohc_regex(/()@YYYY@MM@DD()/gi, '$1@Month @Day, @YYYY$2'); .ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Month @Day, @YYYY$2")
ohc_regex(/()@YYYY@MM@DD()/gi, '$1@Month @Day, @YYYY$2'); .ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Month @Day, @YYYY$2")
ohc_regex(/()@YYYY@MM@DD()/gi, '$1@Month @Day, @YYYY$2'); .ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Month @Day, @YYYY$2");
} }


function ohc_delink_ISO_to_dmy() function ohc_delink_ISO_to_dmy(editor) {
ohc_ISO_to_dmy_in_citations(editor);
{
ohc_ISO_to_dmy_in_references(editor);
ohc_ISO_to_dmy_in_citations();

ohc_ISO_to_dmy_in_references();
editor
regex(/()@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Day @Month @Year$2');
ohc_regex(/(\|\|*)@YYYY@MM@DD(*\|\|)/gi, '$1{{dts|format=dmy|@YYYY|@MM|@DD}}$2'); //dts template for sortable tables .replace(/()@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, "$1@Day @Month @Year$2")
ohc_regex(/(\{\{dts\|format=)mdy\|/gi, '$1dmy|'); //flip dts template formats .ohc_regex(/(\|\|*)@YYYY@MM@DD(*\|\|)/gi, "$1{{dts|format=dmy|@YYYY|@MM|@DD}}$2") // dts template for sortable tables
.ohc_regex(/(\{\{dts\|format=)mdy\|/gi, "$1dmy|"); //flip dts template formats
} }


function ohc_delink_ISO_to_mdy() function ohc_delink_ISO_to_mdy(editor) {
ohc_ISO_to_mdy_in_citations(editor);
{
ohc_ISO_to_mdy_in_references(editor);
ohc_ISO_to_mdy_in_citations();

ohc_ISO_to_mdy_in_references();
editor
regex(/()@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Month @Day, @Year$2');
ohc_regex(/(\|\|*)@YYYY@MM@DD(*\|\|)/gi, '$1{{dts|@YYYY|@MM|@DD}}$2'); //dts template for sortable tables (mdy is default) .replace(/()@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, "$1@Month @Day, @Year$2")
.ohc_regex(/(\|\|*)@YYYY@MM@DD(*\|\|)/gi, "$1{{dts|@YYYY|@MM|@DD}}$2") // dts template for sortable tables (mdy is default)
ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, '$1'); //flip dts template formats .ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, "$1"); // flip dts template formats
} }


function ohc_delink_year_in_X() function ohc_delink_year_in_X(editor) {
editor
{
// ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1"); //disabled 3/5/21 discussion at https://en.wikipedia.org/search/?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox? //.ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1") // disabled 3/5/21 discussion at https://en.wikipedia.org/search/?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox?
// ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1"); //.ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1")
ohc_regex(/\]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, '$1'); .ohc_regex(/\]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, "$1")
regex(/\\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, '$1'); .replace(/\\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, "$1")


regex(/\\]/gi, '$1$2'); .replace(/\\]/gi, "$1$2");
} }




// format parameter must be 'dmy' or 'mdy' // format parameter must be 'dmy' or 'mdy'
function ohc_fix_dts_template(format) function ohc_fix_dts_template(editor, format) {
editor
{
// dts - format=dmy in this case (per D12000) // dts - format=dmy in this case (per D12000)
// per {{dts}} doc, remove the obsolete link=off param // per {{dts}} doc, remove the obsolete link=off param
regex(/(\{\{dts*)(?:\|link=off)/gi, '$1'); .replace(/(\{\{dts*)(?:\|link=off)/gi, "$1")
ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, '$1'+format+'$2'); .ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, "$1"+format+"$2")
ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, '$1'+format+'$2'); .ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, "$1"+format+"$2")
ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, '$1|format='+format+'$2'); .ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, "$1|format="+format+"$2")


// stripping – {{dts}} serves no purpose inside date parameters // stripping – {{dts}} serves no purpose inside date parameters
ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*(*)\}\}(?=\s*)/gi, "$1$2"); .ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*(*)\}\}(?=\s*)/gi, "$1$2")
ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*(*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*)/gi, "$1$2"); .ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*(*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*)/gi, "$1$2")
ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*)/gi, "$1@YYYY-@MM-@DD "); .ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*)/gi, "$1@YYYY-@MM-@DD ")
ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*)/gi, "$1@YYYY-@MM-@DD "); .ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*)/gi, "$1@YYYY-@MM-@DD ");
} }


// format parameter must be 'dmy' or 'mdy' // format parameter must be 'dmy' or 'mdy'
function ohc_fix_gr_template(format) function ohc_fix_gr_template(editor, format) {
editor
{
// GR - date formatting parameter // GR - date formatting parameter
// per {GR} doc, insert date formatting param // per {GR} doc, insert date formatting param
regex(/(\{\{GR\|\d\d?)(?!\|date)/gi, '$1|dateform=' + format); .replace(/(\{\{GR\|\d\d?)(?!\|date)/gi, "$1|dateform=" + format);
} }


function ohc_dates_to_dmy() function ohc_dates_to_dmy(editor) {
editor
{
regex(/\|df={3}(?:-all|)(?=\s*)/gi, ''); .replace(/\|df={3}(?:-all|)(?=\s*)/gi, '')
regex(/\|format=mdy/gi, '|format=dmy'); .replace(/\|format=mdy/gi, "|format=dmy")
//change start and end templates; vgrelease new v=2 or mdy is default
regex(/(\{\{(?:start date|end date)*\|)df=ye?s?\|(*df=ye?s?)/gi, '$1$2');
regex(/(\{\{vgrelease new*\|)(?:v=1\||)({2,3}\|)/g, '$1v=2|$2');
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //spotted at ]
//change birth and death templates
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)*\|)m(f=ye?s?)/gi, '$1d$2'); // substitute df for mf
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)+)(\}\})/gi, '$1|df=y$2'); //insert df parameter
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)+\|)df=ye?s?\|(*df=ye?s?)/gi, '$1$2'); //put date format parameter at the end
regex(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1|20)\d{2}\}\})/gi, '$1$2'); //date format parameter not needed – year only


// change start and end templates; vgrelease new v=2 or mdy is default
//convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
.replace(/(\{\{(?:start date|end date)*\|)df=ye?s?\|(*df=ye?s?)/gi, "$1$2")
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4");
.replace(/(\{\{vgrelease new*\|)(?:v=1\||)({2,3}\|)/g, "$1v=2|$2")
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth");
.ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY") // spotted at ]


// change birth and death templates
// ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth"); //disabling as unlikely and ungrammatical constructions causing false positives
.replace(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)*\|)m(f=ye?s?)/gi, "$1d$2") // substitute df for mf
.replace(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)+)(\}\})/gi, "$1|df=y$2") // insert df parameter
.replace(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)+\|)df=ye?s?\|(*df=ye?s?)/gi, "$1$2") // put date format parameter at the end
.replace(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1|20)\d{2}\}\})/gi, "$1$2") // date format parameter not needed – year only


//'md, md,' to 'dm, dm,' // convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
ohc_regex(/(\D\W)@Month @Day, @Month @Day(?=\W\D)/gi, "$1@Day1 @LMonth1, @Day2 @LMonth2"); .ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4")
.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth")


//.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth") //disabling as unlikely and ungrammatical constructions causing false positives
//convert simple mdy dates to dmy
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth");
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth");


//'md, md,' to 'dm, dm,'
//Month+day_number " 7th March" -> "7 March"
ohc_regex(/(\D\W)@Day\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year"); .ohc_regex(/(\D\W)@Month @Day, @Month @Day(?=\W\D)/gi, "$1@Day1 @LMonth1, @Day2 @LMonth2")
ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");


//convert simple mdy dates to dmy
//dates with embedded nbsp
ohc_regex(/(\D\W)@Month(|&nbsp;)(\d{1,2},(?: |&nbsp;)\d{1,2}(?:\s(?:and|&|to|or)(?:|&nbsp;))\d{1,2})(?=\w])/gi, '$1$3$2@LMonth '); .ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth")
ohc_regex(/(\D\W)@Month(|&nbsp;|{{(?:break|nbsp)}})@Day,(|&nbsp;|{{(?:break|nbsp)}})@YYYY(?=\w])/gi, '$1@Day$2@Month$3@Year'); .ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2")
.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year")
.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth")


//Month+day_number " 7th March" -> "7 March"
//remove comma
ohc_regex(/(\D\W)@Day\s@Month,\s?@Year(?=\W\D)/gi, "$1@Day @LMonth @Year"); .ohc_regex(/(\D\W)@Day\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year")
.ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth")
.ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year")


//dates with embedded nbsp
// remove "the" from "on the dd month"
ohc_regex(/(on |by )the @Day\s@Month(?=)/gi, "$1@Day @LMonth"); .ohc_regex(/(\D\W)@Month(|&nbsp;)(\d{1,2},(?: |&nbsp;)\d{1,2}(?:\s(?:and|&|to|or)(?:|&nbsp;))\d{1,2})(?=\w])/gi, "$1$3$2@LMonth ")
.ohc_regex(/(\D\W)@Month(|&nbsp;|{{(?:break|nbsp)}})@Day,(|&nbsp;|{{(?:break|nbsp)}})@YYYY(?=\w])/gi, "$1@Day$2@Month$3@Year")


//remove space from date range conversion //remove comma
ohc_regex(/(\D ) @Day(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)/gi, "$1@Day$2"); .ohc_regex(/(\D\W)@Day\s@Month,\s?@Year(?=\W\D)/gi, "$1@Day @LMonth @Year")

// remove "the" from "on the dd month"
.ohc_regex(/(on |by )the @Day\s@Month(?=)/gi, "$1@Day @LMonth")

//remove space from date range conversion
.ohc_regex(/(\D ) @Day(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)/gi, "$1@Day$2");
} }


function ohc_dates_to_mdy() function ohc_dates_to_mdy(editor) {
editor
{
//change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default // change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default
regex(/\|df={3}(?:-all|)(?=\s*)/gi, ''); .replace(/\|df={3}(?:-all|)(?=\s*)/gi, '')
regex(/\|df=y(?:es|)(?=)/gi, ''); .replace(/\|df=y(?:es|)(?=)/gi, '')
regex(/(mf=y(?:es|)\|*\|)(?:mf=y(?:es|)\|)/gi, '$1'); .replace(/(mf=y(?:es|)\|*\|)(?:mf=y(?:es|)\|)/gi, "$1")
regex(/(\{\{vgrelease new*\|)(?:v=2\||)({2,3}\|)/g, '$1$2'); .replace(/(\{\{vgrelease new*\|)(?:v=2\||)({2,3}\|)/g, "$1$2")
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY"); .ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY")


//convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d) // convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d)
ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY"); .ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY")
ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2"); .ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2")
// ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY"); //disabling as unlikely and ungrammatical constructions causing false positives //.ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY") // disabling as unlikely and ungrammatical constructions causing false positives
// ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2"); //disabling as unlikely and ungrammatical constructions causing false positives //.ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2") // disabling as unlikely and ungrammatical constructions causing false positives


//'dm, dm,' to 'md, md,' // 'dm, dm,' to 'md, md,'
ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2"); .ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2")


//convert simple dmy dates to mdy // convert simple dmy dates to mdy
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day"); .ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day")
ohc_regex(/(\D\W)@Day(\s|&nbsp;)@Month,?(\s|&nbsp;)@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year"); .ohc_regex(/(\D\W)@Day(\s|&nbsp;)@Month,?(\s|&nbsp;)@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year")
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year"); .ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year")
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day+@Month(?=\W\D)/gi, "$1@LMonth @Day"); .ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day+@Month(?=\W\D)/gi, "$1@LMonth @Day")


//Month+day_number "March 7th" -> "March 7" // Month+day_number "March 7th" -> "March 7"
ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY"); .ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY")
ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month(\s|&nbsp;)@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY"); .ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month(\s|&nbsp;)@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY")
ohc_regex(/(\D\W)@Month(\s|&nbsp;)@Day(?=\W\D)/gi, "$1@LMonth$2@Day"); .ohc_regex(/(\D\W)@Month(\s|&nbsp;)@Day(?=\W\D)/gi, "$1@LMonth$2@Day")
ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month()(?=\W\D)/gi, "$1@LMonth$2@Day$3"); .ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month()(?=\W\D)/gi, "$1@LMonth$2@Day$3")


//add comma where missing // add comma where missing
ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s\w)/gi, "$1@LMonth @Day, @YYYY,"); .ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s\w)/gi, "$1@LMonth @Day, @YYYY,")

//rem superfluous comma where applicable
// rem superfluous comma where applicable
ohc_regex(/(\D)@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
.ohc_regex(/(\D)@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
} }


function ohc_fix_dmy_redundancies() function ohc_fix_dmy_redundancies(editor) {
editor
{
//month-range redundancies (repeating month names) // month-range redundancies (repeating month names)
ohc_regex(/(@dd)@th? @Month{1,2}((?:to|and|-|–){1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) { .ohc_regex(/(@dd)@th? @Month{1,2}((?:to|and|-|–){1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) {
if (d1.m == d2.m) return true; if (d1.m == d2.m) return true;
return false; return false;
}); });
} }

//not currently used
function ohc_fix_mdy_redundancies() function ohc_fix_mdy_redundancies(editor) {
editor
{
//month-range redundancies (repeating month names) // month-range redundancies (repeating month names)
ohc_regex(/(@Month{1,2}@dd)@th? (to|and|-|–){1,2}@Month{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) { .ohc_regex(/(@Month{1,2}@dd)@th? (to|and|-|–){1,2}@Month{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) {
if (d1.m == d2.m) return true; if (d1.m == d2.m) return true;
return false; return false;
}); });
} }


function ohc_expand_ref_dates() function ohc_expand_ref_dates(editor) {
editor
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*)/gi, "$1@FullMonth @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*)/gi, "$1@FullMonth @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*)/gi, "$1@Day @FullMonth @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*)/gi, "$1@Day @FullMonth @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*)/gi, "$1@FullMonth @Day, @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*)/gi, "$1@FullMonth @Day, @YYYY")


ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=\s*)/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=\s*)/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=\s*)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=\s*)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=\s*)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=\s*)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=\s*)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=\s*)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY")
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=\s*)/gi, "$1@$2 – @FullMonth @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=\s*)/gi, "$1@$2 – @FullMonth @YYYY")


ohc_regex(/(<ref*>(?:+?|))((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2"); .ohc_regex(/(<ref*>(?:+?|))((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2")
ohc_regex(/(<ref*>(?:+?|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY"); .ohc_regex(/(<ref*>(?:+?|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY")
ohc_regex(/(<ref*>(?:+?|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY"); .ohc_regex(/(<ref*>(?:+?|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY")
ohc_regex(/(<ref*>(?:+?|))@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY"); .ohc_regex(/(<ref*>(?:+?|))@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY")
ohc_regex(/(<ref*>(?:+?|))((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY"); .ohc_regex(/(<ref*>(?:+?|))((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY");
} }


function ohc_expand_all_dates() function ohc_expand_all_dates(editor) {
editor
{
ohc_regex(/()@Month @YYYY(?=)/gi, '$1@FullMonth @YYYY'); .ohc_regex(/()@Month @YYYY(?=)/gi, "$1@FullMonth @YYYY")
ohc_regex(/()@Day @Month @YYYY(?=)/gi, '$1@Day @FullMonth @YYYY'); .ohc_regex(/()@Day @Month @YYYY(?=)/gi, "$1@Day @FullMonth @YYYY")
ohc_regex(/()@Month @Day, @YYYY(?=)/gi, '$1@FullMonth @Day, @YYYY'); .ohc_regex(/()@Month @Day, @YYYY(?=)/gi, "$1@FullMonth @Day, @YYYY")


ohc_regex(/()((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2"); .ohc_regex(/()((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2")
ohc_regex(/()@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY"); .ohc_regex(/()@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY")
ohc_regex(/()@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY"); .ohc_regex(/()@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY")
ohc_regex(/()@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY"); .ohc_regex(/()@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY")
ohc_regex(/()((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=)/gi, "$1$2 – @FullMonth @YYYY"); .ohc_regex(/()((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=)/gi, "$1$2 – @FullMonth @YYYY")


ohc_regex(/(\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*)/gi, "$1@Day @FullMonth @YYYY"); .ohc_regex(/(\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*)/gi, "$1@Day @FullMonth @YYYY")
ohc_regex(/(\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*)/gi, "$1@FullMonth @Day, @YYYY"); .ohc_regex(/(\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*)/gi, "$1@FullMonth @Day, @YYYY")
ohc_regex(/(\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2"); .ohc_regex(/(\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2")
ohc_regex(/(\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2"); .ohc_regex(/(\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2")
ohc_regex(/(\((?:c\. |))@YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2"); .ohc_regex(/(\((?:c\. |))@YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2")
ohc_regex(/(\((?:c\. |))@Month ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY"); .ohc_regex(/(\((?:c\. |))@Month ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY")
ohc_regex(/(\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY"); .ohc_regex(/(\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY");
} }

function ohc_abbrev_ref_dates(editor) {
editor
.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*)/gi, "$1@Day @Mon @YYYY")
.ohc_regex(/(<ref*>(?:+?|))(?\d|30|31) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il||ust|(?:t?em|o)ber)( (?:19\d|20)\d)(?=(?:*?|)<\/ref>)/gi, "$1$2 $3$4")
.ohc_regex(/(\()@Day @Month @YYYY()/gi, "$1@Day @Mon @YYYY$2")


.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*)/gi, "$1@Mon @Day, @YYYY")
function ohc_abbrev_ref_dates()
.ohc_regex(/(<ref*>(?:+?|))(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il||ust|(?:t?em|o)ber) (?\d|30|31),( (?:19\d|20)\d)(?=(?:*?|)<\/ref>)/gi, "$1$2 $3,$4")
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*)/gi, "$1@Day @Mon @YYYY"); .ohc_regex(/()@Month @Day, @YYYY()/gi, "$1@Mon @Day, @YYYY$2");
ohc_regex(/(<ref*>(?:+?|))(?\d|30|31) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il||ust|(?:t?em|o)ber)( (?:19\d|20)\d)(?=(?:*?|)<\/ref>)/gi, "$1$2 $3$4");
ohc_regex(/(\()@Day @Month @YYYY()/gi, "$1@Day @Mon @YYYY$2");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*)/gi, "$1@Mon @Day, @YYYY");
ohc_regex(/(<ref*>(?:+?|))(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il||ust|(?:t?em|o)ber) (?\d|30|31),( (?:19\d|20)\d)(?=(?:*?|)<\/ref>)/gi, "$1$2 $3,$4");
ohc_regex(/()@Month @Day, @YYYY()/gi, '$1@Mon @Day, @YYYY$2');
} }

//not currently used //not currently used
function ohc_abbrev_all_dates() function ohc_abbrev_all_dates(editor) {
editor
{
ohc_regex(/()@Day @Month @YYYY(?=)/gi, '$1@Day @Mon @YYYY'); .ohc_regex(/()@Day @Month @YYYY(?=)/gi, "$1@Day @Mon @YYYY")
ohc_regex(/()@Month @Day, @YYYY(?=)/gi, '$1@Mon @Day, @YYYY'); .ohc_regex(/()@Month @Day, @YYYY(?=)/gi, "$1@Mon @Day, @YYYY");
} }


//not currently used
function ohc_dmy_publication_dates()
function ohc_dmy_publication_dates(editor) {
{
editor
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
// ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Day @Month @YYYY"); //disabled conversion of yyyy-mm-dd in citation templates (except publication date) .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY") // conversion of dates in references outside of the protection loop (eg for quotations etc.)
ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Day @Month @YYYY"); .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Day @Month @YYYY")


//replace ISO dates (within parentheses) only within refs // replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref*>+?)(\()@YYYY-@MM-@DD(\))(\W*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4"); .ohc_regex(/(<ref*>+?)(\()@YYYY-@MM-@DD(\))(\W*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
} }


function ohc_mdy_publication_dates() function ohc_mdy_publication_dates(editor) {
editor
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.) .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY") // conversion of dates in references outside of the protection loop (eg for quotations etc.)
// ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Month @Day, @YYYY"); //disabled conversion of yyyy-mm-dd in citation templates (except publication date) .ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Month @Day, @YYYY")
ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Month @Day, @YYYY");


//replace ISO dates (within parentheses) only within refs // replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref*>+?)(\()@YYYY-@MM-@DD(\))(\W*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4"); .ohc_regex(/(<ref*>+?)(\()@YYYY-@MM-@DD(\))(\W*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
} }


function ohc_Bigendian_ref_dates() { function ohc_Bigendian_ref_dates(editor) {
editor
// Add a tag to the summary box
// Add a tag to the summary box
regex(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|+\}\})/gi, '$1|cs1-dates=y$2');
.replace(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|+\}\})/gi, "$1|cs1-dates=y$2");
} }


Line 764: Line 809:
// this function modified 2019-03-27 from ] // this function modified 2019-03-27 from ]
// format parameter must be 'dmy' or 'mdy' // format parameter must be 'dmy' or 'mdy'
function ohc_use_dates_template(format) function ohc_use_dates_template(editor, format) {
{
var txt = document.editform.wpTextbox1;
// current month-year // current month-year
var currentDate = new Date(); var currentDate = new Date();
Line 772: Line 815:
var curryear = currentDate.getFullYear(); var curryear = currentDate.getFullYear();
var myMonths = ; var myMonths = ;
var curryyyymm = myMonths + ' ' + curryear; var curryyyymm = myMonths + " " + curryear;


// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument // step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument
editor
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
regex(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *()/gi, '{{Use ' + format + ' dates$1');
.replace(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *()/gi, "{{Use " + format + " dates$1")
// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
regex(/\{\{ *use *(?:dmy|mdy) *()/gi, '{{Use ' + format + ' dates$1');
// strip leading / trailing whitespace from 'use xxx dates'
regex(/\{\{ *use (?:dmy|mdy) dates *()/gi, '{{Use ' + format + ' dates$1');


// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
.replace(/\{\{ *use *(?:dmy|mdy) *()/gi, "{{Use " + format + " dates$1")

// strip leading / trailing whitespace from 'use xxx dates'
.replace(/\{\{ *use (?:dmy|mdy) dates *()/gi, "{{Use " + format + " dates$1");

// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
var rxpdd = new RegExp("{{Use " + format + " dates", "gi"); // here we search for canonical form {{use xxx dates}} that has current date var rxpdd = new RegExp("{{Use " + format + " dates", "gi"); // here we search for canonical form {{use xxx dates}} that has current date
var dflagfound = txt.value.search(rxpdd); var dflagfound = editor.get().search(rxpdd);
if (dflagfound === -1) { if (dflagfound === -1) {
txt.value = '{{Use ' + format + ' dates|date=' + curryyyymm + '}}\r\n' + txt.value; // not found so insert new template at top of wikitext editor.prepend("{{Use " + format + " dates|date=" + curryyyymm + "}}\r\n"); // not found so insert new template at top of wikitext
return; // and done return; // and done
} }


// step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is // step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is
editor
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=*\| *cs1\-dates *= *(*?) *\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |date= followed by |cs1-dates=
regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *(*?) *\| *date *=*\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |cs1-dates= followed by |date= .replace(/(\{\{use (?:dmy|mdy) dates)\| *date *=*\| *cs1\-dates *= *(*?) *\}\}/gi, "$1|date=" + curryyyymm + "|cs1-dates=$2}}") // with |date= followed by |cs1-dates=
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=*\}\}/gi, '$1|date=' + curryyyymm + '}}'); // with |date= .replace(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *(*?) *\| *date *=*\}\}/gi, "$1|date=" + curryyyymm + "|cs1-dates=$2}}") // with |cs1-dates= followed by |date=
regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *(*?) \}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |cs1-dates .replace(/(\{\{use (?:dmy|mdy) dates)\| *date *=*\}\}/gi, "$1|date=" + curryyyymm + "}}") // with |date=
regex(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, '$1|date=' + curryyyymm + '}}'); // no parameters so add |date=curryyyymm .replace(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *(*?) \}\}/gi, "$1|date=" + curryyyymm + "|cs1-dates=$2}}") // with |cs1-dates
regex(/(\{\{*use+(?:dmy|mdy)+dates*\}\})(*)(\{\{*short description*\}\})/gi, '$3$2$1'); // repositioning "short description" template at the top .replace(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, "$1|date=" + curryyyymm + "}}") // no parameters so add |date=curryyyymm
.replace(/(\{\{*use+(?:dmy|mdy)+dates*\}\})(*)(\{\{*short description*\}\})/gi, "$3$2$1"); // repositioning "short description" template at the top
} }


Line 806: Line 853:
var linkmap = ; var linkmap = ;


function ohc_protect_dates() function ohc_protect_dates(editor) {
{
// protects dates within links, quotes, etc // protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier, // the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part. // which is later replaced with the stored part.
var protect_function = function(s, begin, replace, end) { var protect_function = function(s, begin, replace, end) {
linkmap.push(replace); linkmap.push(replace);
return begin + "⍌"+(linkmap.length-1)+"⍍" + end; return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
}; };
//\|x=
regex(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function);
regex(/(<!--)(*?)(-->)/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(/(\{\{(?:Canadian federal by-election))(+)(\}\})/gi, protect_function);
regex(/(\]*)(\])/gi, protect_function);
regex(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function);
regex(/(\|archive-?url=https?:|ftp:)(*)(\|)/gi, protect_function); //repurposed unused line to protect archive url links (archive.today)
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|map\d|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(/(\{\{merge(?:+))(+)(\})/gi, protect_function);
regex(/(\{\{(?:singlechart)\|)(+)(\})/gi, protect_function);
regex(/(\{\{(?:defaultsort|graph):)(+)(\})/gi, protect_function);
regex(/()(*)()/gi, protect_function);
regex(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function);
regex(/(\\]|\|)/gi, protect_function);


editor
//retraining redirects containing a date
// \|x=
regex(/(\\]|\|)/gi, '$1Jiusan Society$2');
.replace(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function)
regex(/(\\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
.replace(/(<!--)(*?)(-->)/gi, protect_function)
regex(/(\\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
.replace(/(<math>)(*?)(<\/math>)/gi, protect_function)
regex(/(\\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
.replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function)
.replace(/(<ref)(+)(>)/gi, protect_function)
.replace(/((?:Category|Image|File):)(]*)(])/gi, protect_function)
.replace(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function)
.replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function)
.replace(/(\{\{(?:harvnb|r|wikisource)\|)(+)(\})/gi, protect_function)
.replace(/(\{\{(?:Canadian federal by-election))(+)(\}\})/gi, protect_function)

.replace(/(\]*)(\])/gi, protect_function)
.replace(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function)
.replace(/(\|archive-?url=https?:|ftp:)(*)(\|)/gi, protect_function) //repurposed unused line to protect archive url links (archive.today)
.replace(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function)
.replace(/(<noinclude>)(*?)(<\/noinclude>)/gi, protect_function)
.replace(/(<gallery)(*?)(<\/gallery>)/gi, protect_function)
.replace(/(<poem>)(*?)(<\/poem>)/gi, protect_function)
.replace(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function)
.replace(/((?:image\d?|image_skyline|imagelocation\d?|imagename|imagefile|img|map\d|pic)\s*=)(*)()/gi, protect_function)
.replace(/(\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)
.replace(/(\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)
.replace(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function)
.replace(/(\s*(?:)\s*=)(\s*+\s*)(\|)/gi, protect_function)
.replace(/(\{\{navsource\|)(+)(\})/gi, protect_function)
.replace(/(\{\{merge(?:+))(+)(\})/gi, protect_function)
.replace(/(\{\{(?:singlechart)\|)(+)(\})/gi, protect_function)
.replace(/(\{\{(?:defaultsort|graph):)(+)(\})/gi, protect_function)
.replace(/()(*)()/gi, protect_function)
.replace(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function)
.replace(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function)
.replace(/(\\]|\|)/gi, protect_function)

// retraining redirects containing a date
.replace(/(\\]|\|)/gi, "$1Jiusan Society$2")
.replace(/(\\]|\|)/gi, "$1Tiananmen Square protests of 1989$2")
.replace(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")
.replace(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")

// protect alternate meanings of 'may' and 'march' (note: not case insensitive)
//.ohc_regex(/()(@day,?\s{0,3}may)()/g, protect_function) //disabled 26 May – not case senstitve: false negatives in converting dates in May
.ohc_regex(/()(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function)


//protect alternate meanings of 'may' and 'march' (note: not case insensitive) // protect all links containing a date and some text
// ohc_regex(/()(@day,?\s{0,3}may)()/g, protect_function); //disabled 26 May – not case senstitve: false negatives in converting dates in May .ohc_regex(/(\\|\n]+?@day\|\n]+?@fullmonth\|\n]*)(\]\]|\|)/gi, protect_function)
ohc_regex(/()(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function); .ohc_regex(/(\\|\n]*?@day\|\n]+?@fullmonth(?:,? @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)
.ohc_regex(/(\\|\n]+?@fullmonth\|\n]+?@day\|\n]*)(\|)/gi, protect_function)
.ohc_regex(/(\\|\n]*?@fullmonth\|\n]+?@day(?:, @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)


// protects certain dates
//protect all links containing a date and some text
ohc_regex(/(\\|\n]+?@day\|\n]+?@fullmonth\|\n]*)(\]\]|\|)/gi, protect_function); .replace(/(\)/gi, protect_function)
ohc_regex(/(\\|\n]*?@day\|\n]+?@fullmonth(?:,? @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function); .replace(/()(March (?:8|14) Alliance)()/gi, protect_function)
ohc_regex(/(\\|\n]+?@fullmonth\|\n]+?@day\|\n]*)(\|)/gi, protect_function); .replace(/()(23rd March 1931: Shaheed)()/gi, protect_function)
ohc_regex(/(\\|\n]*?@fullmonth\|\n]+?@day(?:, @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function); .replace(/()(Long March )()/gi, protect_function)
.replace(/()(National September 11 Memorial & Museum)()/gi, protect_function)
.replace(/()(Queen Elizabeth II September 11th Garden)()/gi, protect_function)
.replace(/()(Bombay March 12)()/gi, protect_function)
.replace(/()(movement 2 June)()/gi, protect_function)
.replace(/()(6th\sof October City)()/gi, protect_function)
.replace(/()(Party Workers' Liberation Front 30th of May)()/gi, protect_function)
.replace(/()(4th\sof August regime)()/gi, protect_function)
.replace(/()(19th\sof April movement)()/gi, protect_function)
.replace(/()(June 4th (?:incident|museum))()/gi, protect_function)
.replace(/()(The Battle Of Marston Moor \(July 2nd,? 1644\))()/gi, protect_function)
.replace(/()(Night of January 16th)()/gi, protect_function)
.replace(/()(Observance of 5th November Act)()/gi, protect_function)
.replace(/(\[\[)(13 May incident)(\|)/gi, protect_function)
.replace(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function)
.replace(/(\\'])/gi, protect_function)
.replace(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function)


.replace(/(\\])/gi, protect_function)
//protects certain dates
regex(/(\)/gi, protect_function); .replace(/(.)(4th\sof July)(.)/gi, protect_function)
regex(/()(March (?:8|14) Alliance)()/gi, protect_function); .replace(/(\\])/gi, protect_function)
regex(/()(23rd March 1931: Shaheed)()/gi, protect_function); .replace(/(\\])/gi, protect_function)
regex(/()(Long March )()/gi, protect_function); .replace(/(\\])/gi, protect_function)
regex(/()(National September 11 Memorial & Museum)()/gi, protect_function);
regex(/()(Queen Elizabeth II September 11th Garden)()/gi, protect_function);
regex(/()(Bombay March 12)()/gi, protect_function);
regex(/()(movement 2 June)()/gi, protect_function);
regex(/()(6th\sof October City)()/gi, protect_function);
regex(/()(Party Workers' Liberation Front 30th of May)()/gi, protect_function);
regex(/()(4th\sof August regime)()/gi, protect_function);
regex(/()(19th\sof April movement)()/gi, protect_function);
regex(/()(June 4th (?:incident|museum))()/gi, protect_function);
regex(/()(The Battle Of Marston Moor \(July 2nd,? 1644\))()/gi, protect_function);
regex(/()(Night of January 16th)()/gi, protect_function);
regex(/()(Observance of 5th November Act)()/gi, protect_function);
regex(/(\[\[)(13 May incident)(\|)/gi, protect_function);
regex(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function);
regex(/(\\'])/gi, protect_function);
regex(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
regex(/(\\])/gi, protect_function);
regex(/(.)(4th\sof July)(.)/gi, protect_function);
regex(/(\\])/gi, protect_function);
regex(/(\\])/gi, protect_function);
regex(/(\\])/gi, protect_function);


// works names // works names
// regex(/(.)(protect string)(.)/gi, protect_function); //.replace(/(.)(protect string)(.)/gi, protect_function)
regex(/(.)(11\/22\/63)(.)/gi, protect_function); .replace(/(.)(11\/22\/63)(.)/gi, protect_function)
regex(/(.)(1\.1\.1994)(.)/gi, protect_function); .replace(/(.)(1\.1\.1994)(.)/gi, protect_function)
regex(/()(2\.13\.61)()/gi, protect_function); .replace(/()(2\.13\.61)()/gi, protect_function)
// regex(/(.)(4th of July, Asbury)(.)/gi, protect_function); //protected above globally //.replace(/(.)(4th of July, Asbury)(.)/gi, protect_function) //protected above globally
regex(/(.)(26 October 1993)(.)/gi, protect_function); .replace(/(.)(26 October 1993)(.)/gi, protect_function)
regex(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function); .replace(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function)
regex(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function); .replace(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function)
regex(/(\[\[|\'\')(August 1914)(.)/gi, protect_function); .replace(/(\[\[|\'\')(August 1914)(.)/gi, protect_function)
ohc_regex(/(\)/gi, protect_function); .ohc_regex(/(\)/gi, protect_function)
ohc_regex(/(\)/gi, protect_function); .ohc_regex(/(\)/gi, protect_function)
// regex(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function); //.replace(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function)
regex(/(August)( 7, 4:15)(.)/gi, protect_function); .replace(/(August)( 7, 4:15)(.)/gi, protect_function)
regex(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function); .replace(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function)
regex(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function); .replace(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function)
ohc_regex(/(Live at *,? \d)( @fullmonth)(.)/gi, protect_function); .ohc_regex(/(Live at *,? \d)( @fullmonth)(.)/gi, protect_function)
ohc_regex(/(Live at *,? @fullmonth)( @dd)(.)/gi, protect_function); .ohc_regex(/(Live at *,? @fullmonth)( @dd)(.)/gi, protect_function)
ohc_regex(/(Bootmoon Series: * @fullmonth)( @day, @YYYY)(.)/gi, protect_function); .ohc_regex(/(Bootmoon Series: * @fullmonth)( @day, @YYYY)(.)/gi, protect_function)


// expressions and grammatical strings including modal "may" // expressions and grammatical strings including modal "may"
// regex(/(trappist-)(\d{1,3})( may )/g, protect_function); //prospective regex if the line below gives false positives //.replace(/(trappist-)(\d{1,3})( may )/g, protect_function) //prospective regex if the line below gives false positives
regex(/(\W)((?:\d{1,3}) may )(\w\w+)/g, protect_function); .replace(/(\W)((?:\d{1,3}) may )(\w\w+)/g, protect_function)
regex(/(\W)((?:\d{3}|3|\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function); .replace(/(\W)((?:\d{3}|3|\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function)
regex(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function); .replace(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
} }


Line 926: Line 973:
var linkmap = ; var linkmap = ;


function ohc_protect_dates_ref() function ohc_protect_dates_ref(editor) {
{
// protects dates within links, quotes, etc // protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier, // the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part. // which is later replaced with the stored part.

var protect_function = function (s, begin, replace, end) { var protect_function = function (s, begin, replace, end) {
linkmap.push(replace); linkmap.push(replace);
Line 937: Line 982:
}; };


editor
regex(/(<ref\s?(?:>|name=+))(+)(<\/ref>)/gi, protect_function);
regex(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function); .replace(/(<ref\s?(?:>|name=+))(+)(<\/ref>)/gi, protect_function)
regex(/(<math>)(*?)(<\/math>)/gi, protect_function); .replace(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function)
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function); .replace(/(<math>)(*?)(<\/math>)/gi, protect_function)
regex(/((?:Category|Image|File):)(]*)(])/gi, protect_function); .replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function)
regex(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function); .replace(/((?:Category|Image|File):)(]*)(])/gi, protect_function)
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function); .replace(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function)
regex(/(\{\{(?:harvnb|wikisource)\|)(+)(\})/gi, protect_function); .replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function)
regex(/(\]*)(\])/gi, protect_function); .replace(/(\{\{(?:harvnb|wikisource)\|)(+)(\})/gi, protect_function)
regex(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function); .replace(/(\]*)(\])/gi, protect_function)
regex(/(\|archive-?url=https?:|ftp:)(*)(\|)/gi, protect_function); //repurposed unused line to protect archive url links (archive.today) .replace(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function)
.replace(/(\|archive-?url=https?:|ftp:)(*)(\|)/gi, protect_function) //repurposed unused line to protect archive url links (archive.today)
regex(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function); .replace(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function)
regex(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function); .replace(/(\{{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); .replace(/((?: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|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function); .replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|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|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function); .replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|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); .replace(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function)
regex(/(\{\{navsource\|)(+)(\})/gi, protect_function); .replace(/(\{\{navsource\|)(+)(\})/gi, protect_function)
regex(/(\{\{singlechart\|)(+)(\})/gi, protect_function); .replace(/(\{\{singlechart\|)(+)(\})/gi, protect_function)
regex(/(\{\{defaultsort:)(+)(\})/gi, protect_function); .replace(/(\{\{defaultsort:)(+)(\})/gi, protect_function)
regex(/(")(*)(")/gi, protect_function); .replace(/(")(*)(")/gi, protect_function)
regex(/(“)(*)(”)/gi, protect_function); .replace(/(“)(*)(”)/gi, protect_function)
regex(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function); .replace(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function)
regex(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function); .replace(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function)


//retraining redirects containing a date // retraining redirects containing a date
regex(/(\\]|\|)/gi, '$1Jiusan Society$2'); .replace(/(\\]|\|)/gi, "$1Jiusan Society$2")
regex(/(\\]|\|)/gi, '$1Tiananmen Square protests of 1989$2'); .replace(/(\\]|\|)/gi, "$1Tiananmen Square protests of 1989$2")
ohc_regex(/(\\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2'); .ohc_regex(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")
ohc_regex(/(\\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2'); .ohc_regex(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")


//protect alternate meanings of 'may' and 'march' (note: not case insensitive) // protect alternate meanings of 'may' and 'march' (note: not case insensitive)
ohc_regex(/()(@day,?\s{0,3}may)()/g, protect_function); .ohc_regex(/()(@day,?\s{0,3}may)()/g, protect_function)
ohc_regex(/()(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function); .ohc_regex(/()(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function)


//protect all links containing a date and some text // protect all links containing a date and some text
ohc_regex(/(\\|\n]+?@day\|\n]+?@fullmonth\|\n]*)(\]\]|\|)/gi, protect_function); .ohc_regex(/(\\|\n]+?@day\|\n]+?@fullmonth\|\n]*)(\]\]|\|)/gi, protect_function)
ohc_regex(/(\\|\n]*?@day\|\n]+?@fullmonth(?:,? @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function); .ohc_regex(/(\\|\n]*?@day\|\n]+?@fullmonth(?:,? @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)
ohc_regex(/(\\|\n]+?@fullmonth\|\n]+?@day\|\n]*)(\|)/gi, protect_function); .ohc_regex(/(\\|\n]+?@fullmonth\|\n]+?@day\|\n]*)(\|)/gi, protect_function)
ohc_regex(/(\\|\n]*?@fullmonth\|\n]+?@day(?:, @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function); .ohc_regex(/(\\|\n]*?@fullmonth\|\n]+?@day(?:, @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)


//protects certain dates // protects certain dates
regex(/(\)/gi, protect_function); .replace(/(\)/gi, protect_function)
regex(/()(March (?:8|14) Alliance)()/gi, protect_function); .replace(/()(March (?:8|14) Alliance)()/gi, protect_function)
regex(/()(23rd March 1931: Shaheed)()/gi, protect_function); .replace(/()(23rd March 1931: Shaheed)()/gi, protect_function)
regex(/()(Long March )()/gi, protect_function); .replace(/()(Long March )()/gi, protect_function)
regex(/()(Bombay March 12)()/gi, protect_function); .replace(/()(Bombay March 12)()/gi, protect_function)
regex(/()(movement 2 June)()/gi, protect_function); .replace(/()(movement 2 June)()/gi, protect_function)
regex(/()(6th\sof October City)()/gi, protect_function); .replace(/()(6th\sof October City)()/gi, protect_function)
regex(/()(Party Workers' Liberation Front 30th of May)()/gi, protect_function); .replace(/()(Party Workers' Liberation Front 30th of May)()/gi, protect_function)
regex(/()(4th\sof August regime)()/gi, protect_function); .replace(/()(4th\sof August regime)()/gi, protect_function)
regex(/()(19th\sof April movement)()/gi, protect_function); .replace(/()(19th\sof April movement)()/gi, protect_function)
regex(/()(June 4th incident)()/gi, protect_function); .replace(/()(June 4th incident)()/gi, protect_function)
regex(/()(The Battle Of Marston Moor \(July 2nd,? 1644\))()/gi, protect_function); .replace(/()(The Battle Of Marston Moor \(July 2nd,? 1644\))()/gi, protect_function)
regex(/()(Night of January 16th)()/gi, protect_function); .replace(/()(Night of January 16th)()/gi, protect_function)
regex(/()(Observance of 5th November Act)()/gi, protect_function); .replace(/()(Observance of 5th November Act)()/gi, protect_function)
regex(/(\[\[)(13 May incident)(\|)/gi, protect_function); .replace(/(\[\[)(13 May incident)(\|)/gi, protect_function)
regex(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function); .replace(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function)
regex(/(\\'])/gi, protect_function); .replace(/(\\'])/gi, protect_function)
regex(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function); .replace(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function)
regex(/(\\])/gi, protect_function);
regex(/(.)(4th\sof July)(.)/gi, protect_function);
regex(/(\\])/gi, protect_function);
regex(/(\\])/gi, protect_function);
regex(/(\\])/gi, protect_function);


.replace(/(\\])/gi, protect_function)
// works names
//regex(/(.)(protect string)(.)/gi, protect_function); .replace(/(.)(4th\sof July)(.)/gi, protect_function)
regex(/(.)(11\/22\/63)(.)/gi, protect_function); .replace(/(\\])/gi, protect_function)
regex(/(.)(1\.1\.1994)(.)/gi, protect_function); .replace(/(\\])/gi, protect_function)
regex(/()(2\.13\.61)()/gi, protect_function); .replace(/(\\])/gi, protect_function)
//regex(/(.)(4th of July, Asbury)(.)/gi, protect_function); //protected above globally
regex(/(.)(26 October 1993)(.)/gi, protect_function);
regex(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function);
regex(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function);
regex(/(\[\[|\'\')(August 1914)(.)/gi, protect_function);
ohc_regex(/(\)/gi, protect_function);
ohc_regex(/(\)/gi, protect_function);
//regex(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function);
regex(/(August)( 7, 4:15)(.)/gi, protect_function);
regex(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function);
regex(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function);
ohc_regex(/(Live at *,? \d)( @fullmonth)(.)/gi, protect_function);
ohc_regex(/(Live at *,? @fullmonth)( @dd)(.)/gi, protect_function);
ohc_regex(/(Bootmoon Series: * @fullmonth)( @day, @YYYY)(.)/gi, protect_function);


// works names
regex(/(\W)((?:\d{3}|3|\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function);
regex(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function); //.replace(/(.)(protect string)(.)/gi, protect_function)
.replace(/(.)(11\/22\/63)(.)/gi, protect_function)
.replace(/(.)(1\.1\.1994)(.)/gi, protect_function)
.replace(/()(2\.13\.61)()/gi, protect_function)
//.replace(/(.)(4th of July, Asbury)(.)/gi, protect_function) //protected above globally
.replace(/(.)(26 October 1993)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function)
.replace(/(\[\[|\'\')(August 1914)(.)/gi, protect_function)
.ohc_regex(/(\)/gi, protect_function)
.ohc_regex(/(\)/gi, protect_function)
//.replace(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function)
.replace(/(August)( 7, 4:15)(.)/gi, protect_function)
.replace(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function)
.replace(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function)
.ohc_regex(/(Live at *,? \d)( @fullmonth)(.)/gi, protect_function)
.ohc_regex(/(Live at *,? @fullmonth)( @dd)(.)/gi, protect_function)
.ohc_regex(/(Bootmoon Series: * @fullmonth)( @day, @YYYY)(.)/gi, protect_function)

.replace(/(\W)((?:\d{3}|3|\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function)
.replace(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
} }


Line 1,034: Line 1,080:
var linkmap = ; var linkmap = ;


function ohc_protect_dates_slash() function ohc_protect_dates_slash(editor) {
{
// protects dates within links, quotes, etc // protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier, // the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part. // which is later replaced with the stored part.

var protect_function = function (s, begin, replace, end) { var protect_function = function (s, begin, replace, end) {
linkmap.push(replace); linkmap.push(replace);
Line 1,045: Line 1,089:
}; };


editor
regex(/(<ref\s?(?:>|name=+))(+)(<\/ref>)/gi, protect_function);
regex(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function); .replace(/(<ref\s?(?:>|name=+))(+)(<\/ref>)/gi, protect_function)
regex(/(<math>)(*?)(<\/math>)/gi, protect_function); .replace(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function)
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function); .replace(/(<math>)(*?)(<\/math>)/gi, protect_function)
regex(/((?:Category|Image|File):)(]*)(])/gi, protect_function); .replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function)
regex(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function); .replace(/((?:Category|Image|File):)(]*)(])/gi, protect_function)
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function); .replace(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function)
regex(/(\{\{(?:harvnb|wikisource)\|)(+)(\})/gi, protect_function); .replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function)
regex(/(\]*)(\])/gi, protect_function); .replace(/(\{\{(?:harvnb|wikisource)\|)(+)(\})/gi, protect_function)
regex(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function); .replace(/(\]*)(\])/gi, protect_function)
//regex(/(https?:|ftp:)(]*)(])/gi, protect_function); .replace(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function)
regex(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function); //.replace(/(https?:|ftp:)(]*)(])/gi, protect_function)
regex(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function); .replace(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function)
regex(/((?:image\d?|image_skyline|imagelocation\d?|imagename|imagefile|img|pic)\s*=)(*)()/gi, protect_function); .replace(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function)
regex(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function); .replace(/((?: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|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function); .replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|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); .replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function)
regex(/(\{\{navsource\|)(+)(\})/gi, protect_function); .replace(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function)
regex(/(\{\{singlechart\|)(+)(\})/gi, protect_function); .replace(/(\{\{navsource\|)(+)(\})/gi, protect_function)
regex(/(\{\{defaultsort:)(+)(\})/gi, protect_function); .replace(/(\{\{singlechart\|)(+)(\})/gi, protect_function)
regex(/(")(*)(")/gi, protect_function); .replace(/(\{\{defaultsort:)(+)(\})/gi, protect_function)
regex(/()(*)()/gi, protect_function); .replace(/(")(*)(")/gi, protect_function)
regex(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function); .replace(/()(*)(”)/gi, protect_function)
regex(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function); .replace(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function)
.replace(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function);

} }


function ohc_unprotect_dates() function ohc_unprotect_dates(editor) {
editor
{
//unprotect all dates //unprotect all dates
regex(//g, ''); .replace(//g, '')
regex(/⍌(+)⍍/g, function (x, n) { .replace(/⍌(+)⍍/g, function (x, n) {
var res = linkmap;
res = res.replace(/⍌(+)⍍/g, function (x, n) {
var res = linkmap; var res = linkmap;
res = res.replace(/⍌(+)⍍/g, function (x, n) { res = res.replace(/⍌(+)⍍/g, function (x, n) {
var res = linkmap; var res = linkmap;
res = res.replace(/⍌(+)⍍/g, function (x, n) { res = res.replace(/⍌(+)⍍/g, function (x, n) {
return linkmap; var res = linkmap;
res = res.replace(/⍌(+)⍍/g, function (x, n) {
return linkmap;
});
return res;
}); });
return res; return res;
Line 1,089: Line 1,135:
return res; return res;
}); });
return res;
});
} }


function ohc_MOSNUM_edit_summary() function ohc_MOSNUM_edit_summary(editor) {
editor
{
.options({ minor: true })
//Add a tag to the summary box
.appendEditSummary("]-assisted date audit and style fixes per ]")
setoptions(minor = 'true');
.clickDiff();
setreason(']-assisted date audit and style fixes per ]', 'append');
doaction('diff');
} }


function ohc_bigendien_edit_summary() function ohc_bigendien_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions(minor = 'true'); .options({ minor: true })
setreason('ymd ref dates', 'append'); .appendEditSummary("ymd ref dates")
.clickDiff();
doaction('diff');
} }


function ohc_expand_edit_summary() function ohc_expand_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions(minor = 'true'); .options({ minor: true })
setreason('expand month names', 'append'); .appendEditSummary("expand month names")
.clickDiff();
doaction('diff');
} }


function ohc_slash_edit_summary() function ohc_slash_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions(minor = 'true'); .options({ minor: true })
setreason('resolved slash dates', 'append'); .appendEditSummary("resolved slash dates")
.clickDiff();
doaction('diff');
} }


function ohc_abbrev_edit_summary() function ohc_abbrev_edit_summary(editor) {
// add a tag to the summary box
{
editor
//Add a tag to the summary box
setoptions(minor = 'true'); .options({ minor: true })
setreason('abbrev month names', 'append'); .appendEditSummary("abbrev month names")
.clickDiff();
doaction('diff');
} }


/** ------------------------------------------------------------------------ **/ /** ------------------------------------------------------------------------ **/
/// CUSTOMIZATION POINTS /// CUSTOMIZATION POINTS
function ohc_customize_all_to_dmy() { function ohc_customize_all_to_dmy(editor) { }
function ohc_customize_all_to_mdy(editor) { }
}
function ohc_customize_body_to_dmy(editor) { }
function ohc_customize_body_to_mdy(editor) { }
function ohc_customize_ISO_to_dmy(editor) { }
function ohc_customize_ISO_to_mdy(editor) { }


/** ------------------------------------------------------------------------ **/
function ohc_customize_all_to_mdy() {
function ohc_body_dates_to_dmy(editor) {
}
ohc_use_dates_template(editor, "dmy");


ohc_fix_common_errors(editor);
function ohc_customize_body_to_dmy() {
ohc_fix_dts_template(editor, "dmy");
ohc_fix_gr_template(editor, "dmy");
ohc_dates_to_dmy(editor);
ohc_remove_leading_zeroes(editor);
ohc_fix_dmy_redundancies(editor);
} }


function ohc_customize_body_to_mdy() { function ohc_body_dates_to_mdy(editor) {
ohc_use_dates_template(editor, "mdy");
ohc_fix_common_errors(editor);
ohc_fix_dts_template(editor, "mdy");
ohc_fix_gr_template(editor, "mdy");
ohc_dates_to_mdy(editor);
ohc_remove_leading_zeroes(editor);
ohc_fix_mdy_redundancies(editor);
} }


/** ------------------------------------------------------------------------ **/
function ohc_customize_ISO_to_dmy() {
function ohc_all_to_dmy_driver(editor) {
}
ohc_extend_editor(editor);


ohc_delink_dates(editor);
function ohc_customize_ISO_to_mdy() {
ohc_protect_dates(editor);
ohc_fix_unambiguous_dates(editor);
ohc_body_dates_to_dmy(editor);
ohc_delink_ISO_to_dmy(editor);
//ohc_delink_year_in_X(editor);
ohc_customize_all_to_dmy(editor);
ohc_ISO_to_dmy_in_citations(editor);
ohc_unprotect_dates(editor);

ohc_MOSNUM_edit_summary(editor);
} }


function ohc_all_to_mdy_driver(editor) {
/** ------------------------------------------------------------------------ **/
ohc_extend_editor(editor);
function ohc_body_dates_to_dmy()
{
ohc_use_dates_template('dmy');


ohc_delink_dates(editor);
ohc_fix_common_errors();
ohc_protect_dates(editor);
ohc_fix_dts_template('dmy');
ohc_fix_unambiguous_dates(editor);
ohc_fix_gr_template('dmy');
ohc_body_dates_to_mdy(editor);
ohc_dates_to_dmy();
ohc_delink_ISO_to_mdy(editor);
ohc_remove_leading_zeroes();
//ohc_delink_year_in_X(editor);
ohc_fix_dmy_redundancies();
ohc_customize_all_to_mdy();
}
ohc_ISO_to_mdy_in_citations(editor);
ohc_unprotect_dates(editor);


ohc_MOSNUM_edit_summary(editor);
function ohc_body_dates_to_mdy()
{
ohc_use_dates_template('mdy');
ohc_fix_common_errors();
ohc_fix_dts_template('mdy');
ohc_fix_gr_template('mdy');
ohc_dates_to_mdy();
ohc_remove_leading_zeroes();
ohc_fix_mdy_redundancies();
} }


function ohc_dmy_publication_dates_driver(editor) {
/** ------------------------------------------------------------------------ **/
ohc_extend_editor(editor);
function ohc_all_to_dmy_driver(e)
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_dmy();
ohc_delink_ISO_to_dmy();
// ohc_delink_year_in_X();
ohc_customize_all_to_dmy();
ohc_ISO_to_dmy_in_citations();
ohc_unprotect_dates();


//ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates(editor);
ohc_body_dates_to_dmy(editor);
ohc_customize_body_to_dmy(editor);
ohc_dmy_publication_dates(editor);
ohc_unprotect_dates(editor);

ohc_MOSNUM_edit_summary(editor);
} }


function ohc_all_to_mdy_driver(e) function ohc_mdy_publication_dates_driver(editor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_mdy();
ohc_delink_ISO_to_mdy();
// ohc_delink_year_in_X();
ohc_customize_all_to_mdy();
ohc_ISO_to_mdy_in_citations();
ohc_unprotect_dates();


//ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates(editor);
}
ohc_body_dates_to_mdy(editor);
ohc_customize_body_to_mdy(editor);
ohc_mdy_publication_dates(editor);
ohc_unprotect_dates(editor);


ohc_MOSNUM_edit_summary(editor);
function ohc_dmy_publication_dates_driver(e)
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_dmy();
ohc_customize_body_to_dmy();
ohc_dmy_publication_dates();
ohc_unprotect_dates();


ohc_MOSNUM_edit_summary();
} }


function ohc_mdy_publication_dates_driver(e) function ohc_body_to_dmy_driver(editor) {
ohc_extend_editor(editor);
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_mdy();
ohc_customize_body_to_mdy();
ohc_mdy_publication_dates();
ohc_unprotect_dates();


//ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates_ref(editor);
ohc_body_dates_to_dmy(editor);
ohc_customize_body_to_dmy(editor);
ohc_unprotect_dates(editor);


ohc_MOSNUM_edit_summary(editor);
} }


function ohc_body_to_dmy_driver(e) function ohc_body_to_mdy_driver(editor) {
ohc_extend_editor(editor);
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates_ref();
ohc_body_dates_to_dmy();
ohc_customize_body_to_dmy();
ohc_unprotect_dates();


//ohc_delink_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_protect_dates_ref(editor);
ohc_body_dates_to_mdy(editor);
ohc_customize_body_to_mdy(editor);
ohc_unprotect_dates(editor);

ohc_MOSNUM_edit_summary(editor);
} }


function ohc_body_to_mdy_driver(e) function ohc_ISO_to_dmy_driver(editor) {
ohc_extend_editor(editor);
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates_ref();
ohc_body_dates_to_mdy();
ohc_customize_body_to_mdy();
ohc_unprotect_dates();


ohc_protect_dates(editor);
ohc_MOSNUM_edit_summary();
ohc_delink_ISO_to_dmy(editor);
ohc_customize_ISO_to_dmy(editor);
ohc_unprotect_dates(editor);

//ohc_MOSNUM_edit_summary(editor);
} }


function ohc_ISO_to_dmy_driver(e) function ohc_ISO_to_mdy_driver(editor) {
ohc_extend_editor(editor);
{

e.preventDefault();
ohc_protect_dates(); ohc_protect_dates(editor);
ohc_delink_ISO_to_mdy(editor);
ohc_delink_ISO_to_dmy();
ohc_customize_ISO_to_mdy(editor);
ohc_customize_ISO_to_dmy();
ohc_unprotect_dates(); ohc_unprotect_dates(editor);


// ohc_MOSNUM_edit_summary(); //ohc_MOSNUM_edit_summary(editor);
} }


function ohc_ISO_to_mdy_driver(e) { function ohc_delink_year_in_X_driver(editor) {
ohc_extend_editor(editor);
e.preventDefault();
ohc_protect_dates();
ohc_delink_ISO_to_mdy();
ohc_customize_ISO_to_mdy();
ohc_unprotect_dates();


ohc_delink_year_in_X(editor);
// ohc_MOSNUM_edit_summary();
} }


function ohc_delink_year_in_X_driver(e) function ohc_expand_ref_dates_driver(editor) {
ohc_extend_editor(editor);
{
e.preventDefault();
ohc_delink_year_in_X();
}


ohc_expand_ref_dates(editor);
function ohc_expand_ref_dates_driver(e) {
ohc_protect_dates(editor);
e.preventDefault();
ohc_unprotect_dates(editor);
ohc_expand_ref_dates();
ohc_expand_edit_summary(editor);
ohc_protect_dates();
ohc_unprotect_dates();
ohc_expand_edit_summary();
} }


function ohc_expand_all_dates_driver(e) function ohc_expand_all_dates_driver(editor) {
ohc_extend_editor(editor);
{

e.preventDefault();
ohc_expand_ref_dates(); ohc_expand_ref_dates(editor);
ohc_protect_dates(); ohc_protect_dates(editor);
ohc_expand_all_dates(); ohc_expand_all_dates(editor);
ohc_unprotect_dates(); ohc_unprotect_dates(editor);
ohc_expand_edit_summary(); ohc_expand_edit_summary(editor);
} }


function ohc_abbrev_ref_dates_driver(e) function ohc_abbrev_ref_dates_driver(editor) {
ohc_extend_editor(editor);
{

e.preventDefault();
ohc_protect_dates(); ohc_protect_dates(editor);
ohc_abbrev_ref_dates(); ohc_abbrev_ref_dates(editor);
ohc_unprotect_dates(); ohc_unprotect_dates(editor);
ohc_slash_edit_summary(); ohc_slash_edit_summary(editor);
} }


function ohc_UK_slash_dates_driver(e) function ohc_UK_slash_dates_driver(editor) {
ohc_extend_editor(editor);
{

e.preventDefault();
ohc_expand_ref_dates(); ohc_expand_ref_dates(editor);
ohc_protect_dates_slash(); ohc_protect_dates_slash(editor);
ohc_UK_slash_dates_to_dmy(); ohc_UK_slash_dates_to_dmy(editor);
ohc_unprotect_dates(); ohc_unprotect_dates(editor);
ohc_slash_edit_summary(); ohc_slash_edit_summary(editor);
} }


function ohc_US_slash_dates_driver(e) function ohc_US_slash_dates_driver(editor) {
ohc_extend_editor(editor);
{

e.preventDefault();
ohc_expand_ref_dates(); ohc_expand_ref_dates(editor);
ohc_protect_dates_slash(); ohc_protect_dates_slash(editor);
ohc_US_slash_dates_to_mdy(); ohc_US_slash_dates_to_mdy(editor);
ohc_unprotect_dates(); ohc_unprotect_dates(editor);
ohc_expand_edit_summary(); ohc_expand_edit_summary(editor);
} }



Revision as of 14:59, 28 June 2022

// This script aligns dates into one of two formats allowed by ].
// PLEASE READ THE DOCUMENTATION at ] (click on the link above) before using.

// Feedback and constructive criticism are welcome

// <pre>
$.when(
	$.ajax("//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js", { dataType: "script", cache: true }),
	$.ajax("//en.wikipedia.org/search/?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript", { dataType: "script", cache: true })
).then(function() {
	pathoschild.TemplateScript.add(
		[
			{
				name: "DATES to dmy",
				tooltip: "Align all dates to dmy",
				script: ohc_all_to_dmy_driver
			},
			{
				name: "DATES to mdy",
				tooltip: "Align all dates to mdy",
				script: ohc_all_to_mdy_driver
			},
			/*{
				name: "Expand ref dates",
				tooltip: "Expand month names within refs",
				script: ohc_expand_ref_dates_driver
			},
			{
				name: "Expand all dates",
				tooltip: "Expand month names throughout",
				script: ohc_expand_all_dates_driver
			},*/
			{
				name: "US-slash dates",
				tooltip: "US-slash",
				script: ohc_US_slash_dates_driver
			},
			{
				name: "UK-slash dates",
				tooltip: "UK-slash",
				script: ohc_UK_slash_dates_driver
			}
		],

		// common options
		{ forActions: "edit", category: "MOSNUM Dates" }
	);
});

/**
 * Add custom extension methods to the TemplateScript editor.
 * @param editor The TemplateScript editor to extend.
 */
function ohc_extend_editor(editor) {
	editor.ohc_regex = function(rg, sub, func) {
		var text = editor.get();
		text = ohc.dateutil.regex(text, rg, sub, func);
		editor.set(text);

		return editor;
	};
}

function ohc_fix_unambiguous_dates(editor) {
	editor
		// resolvable ambiguous date formats
		// UK style
		.ohc_regex(/()@DD\.@MM\.@YYYY(?=)/gi, "$1@Day @Month @YYYY", function(d) {
			if (d.d == d.m) return true;
			if (d.d > 12) return true;
			return false;
		})
		.ohc_regex(/()@DD\/@MM\/@YYYY(?=)/gi, "$1@Day @Month @YYYY", function(d) {
			if (d.d == d.m) return true;
			if (d.d > 12) return true;
			return false;
		})

		// US style
		.ohc_regex(/()@MM\.@DD\.@YYYY(?=)/gi, "$1@Month @Day, @YYYY", function(d) {
			if (d.d > 12) return true;
			return false;
		})
		.ohc_regex(/()@MM\/@DD\/@YYYY(?=)/gi, "$1@Month @Day, @YYYY", function(d) {
			if (d.d > 12) return true;
			return false;
		});
}

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

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

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

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

function ohc_remove_leading_zeroes(editor) {
	editor
		.ohc_regex(/(\D)@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear")
		.ohc_regex(/(\D)@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day")
		.ohc_regex(/(\D)@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear")
		.ohc_regex(/(\D)@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
}

function ohc_delink_dates(editor) {
	editor
		// add missing space between wikilinks
		.replace(/(\]\])(\[\[)/gi, "$1 $2") // remove (?!file:) to ensure a space between all links

		// rem redundant quote marks and parentheses
		.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'(]*)\'\'\'(?=\s*)/gi, "$1$2")
		.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'(]*)\'\'(?=\s*)/gi, "$1$2")
		.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"(]*)\"(?=\s*)/gi, "$1$2")
		.replace(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\((]*)\)(?=\s*)/gi, "$1$2")

		// delink unpiped dates
		// delink full dates
		.ohc_regex(/\(?:of)?@Month(?:\]\]\s?\\]/gi, "@Day @LMonth @YYYY")
		.ohc_regex(/\\],? \\]/gi, "@LMonth @Day, @YYYY")

		// delink yyyy-mm-dd dates
		.ohc_regex(/\\]-\\]/gi, "@YYYY-@MM-@DD")
		.ohc_regex(/@YYYY-\\]/gi, "@YYYY-@MM-@DD")

		// underscore and nbsp in linked dates
		.ohc_regex(/\\]/gi, "@Day @LMonth")
		.ohc_regex(/\\]@th?/gi, "@LMonth @Day") //consolidated regex with flexible removal of ordinal simple date
		.ohc_regex(/\\]/gi, "@Day @LMonth")
		.ohc_regex(/\\]/gi, "@LMonth @YYYY")
		.ohc_regex(/\\]/gi, "@YYYY")

		// remove leading zero and links from linked date
		.ohc_regex(/\|&nbsp;)@ZD@th\]\]/gi, "@LMonth @Day")
		.ohc_regex(/\|&nbsp;)@Month\]\]/gi, "@Day @LMonth")

		// remove nowrap template from dm and md dates
		.ohc_regex(/(date*=*)\{\{(?:j|no ?(?:break|wrap))\|(?:@DD(?:|&nbsp;)@Month)( @yyyy|)\}\}/gi, "$1@DD @LMonth$2")
		.ohc_regex(/(date*=*)\{\{(?:j|no ?(?:break|wrap))\|(?:@Month(?:|&nbsp;)@DD)( @yyyy|)\}\}/gi, "$1@LMonth @DD$2")

		// delink single dm or 'dth the m'
		.ohc_regex(/(?:the\s)?\(?:of)?@Month\]\]/gi, "@Day @LMonth")

		// delink single md or 'm the dth'
		.ohc_regex(/\(?:the)?@Day@th?\]\](?=\W)/gi, "@LMonth @Day")

		// month+day piped
		.ohc_regex(/\(?:of)?@month|@month@dd@th?)\|((?:@month |)@day)@th?\]\]/gi, "$1")
		.ohc_regex(/\(?:of)?@month|@month@dd@th?)\|@Day@th?(@month|)\]\]/gi, "@Day $1")
		//.ohc_regex(/\+|)\|(]+)@th?\]\]/gi, "$1")
		//.ohc_regex(/\+|)\|(]+)@th?\]\]/gi, "$1")
		.ohc_regex(/\+|)\|(]+)\]\]/gi, "$1")

		// month+day+year pseudo-ISO dates
		.ohc_regex(/\\]-(?:\*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY")
		.ohc_regex(/\\]-(?:\*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY")

		//']Xyyyy ' to 'month day, year'
		.ohc_regex(/\\].@YYYY/gi, "@LMonth @Day, @YYYY")

		//']Xyyyy' to 'day month year'
		.ohc_regex(/\\].@YYYY/gi, "@Day @LMonth @YYYY")

		// century
		.replace(/\first)centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, "$1")
		.replace(/\first)centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|(]{1,30})\]\]/gi, "$1")
		.replace(/\d|th))(centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, "$1 $2$3")
		.ohc_regex(/\centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|(]{1,30})\]\]/gi, "$1")

		// months
		.ohc_regex(/\\]/gi, "@LMonth")
		.ohc_regex(/\]{1,30})\]\]/gi, "$1")

		// decades and years
		.replace(/(\d{1,3}0)?s/g, "$1s")
		.replace(/\\]/g, "$1s")
		.replace(/\]{1,30})\]\]/g, "$1")
		.replace(/\\]/gi, "$1$2 $3")
		.replace(/\?)(AD|BC|CE|BCE)\]\]/gi, "$1$2")
		.replace(/\?)(\d{1,4})\]\]/gi, "$1$2$3")
		.ohc_regex(/()\\]/gi, "$1$2") // piped year
		.replace(/\\d{3}|\d{0,2})\]\]/gi, "$1")
		.replace(/\]{1,30})\]\]/gi, "$1")
		.replace(/\]{1,30})\]\]/gi, "$1")

		// month+year
		// Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
		.ohc_regex(/\]+\|@Day @Month @YYYY\]\]/gi, "@Day @LMonth @YYYY")
		.ohc_regex(/\]+\|@Month @Day,? @YYYY\]\]/gi, "@LMonth @Day, @YYYY")
		.ohc_regex(/\]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2")
		.ohc_regex(/\]+\|(@month|@yyyy)\]\]/gi, "$1")
		.ohc_regex(/\\]/gi, "$1")
		.ohc_regex(/\]{1,30})\]\]/gi, "$1")
		.ohc_regex(/\\](?= {2}^B)/gi, "@YYYY")

		.ohc_regex(/(\]+\|@yyyy)(\]\])( season)/gi, "$1$3$2")

		// removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
		//.ohc_regex(/\\(\)]{1,32}\|@YYYY\]\]/gi, "@Year");  // 23/6/2021 – disabled delinking "other" year-in articles

		// Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
		.ohc_regex(/\]+\|@Month\]\]/gi, "@LMonth")
		.ohc_regex(/\]{3,12}\|@Year\]\]/gi, "@Year")

		// month and day piped
		.ohc_regex(/\@day\|@MM-@DD\]\]/gi, "@MM-@DD")
		.ohc_regex(/\@day\|(]{1,30})\]\]/gi, "$1")
		.ohc_regex(/\|)?@month\|(]{1,30})\]\]/gi, "$1")

		// years piped
		.replace(/\]{1,30})\]\]/gi, "$1");
}

function ohc_fix_common_errors(editor) {
	editor
		.ohc_regex(/(\d)<sup>@th<\/sup>/gi, "$1th")

		// remove dashbot comment from dates
		.replace(/<!-- ?DASHBot ?-->/gi, '')
		.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=*)/gi, "$1c. $2") // add space

		// common cs1 errors
		.replace(/(\|\s*(?:date|year)\s*=)\s*(1\d|20)\?(?=*)/gi, "$1c. $20")
		.replace(/(\|\s*(?:date|year)\s*=\s*(1)\d{2})(\d{2})(?=*)/gi, "$1–$2$3")
		//.replace(/(\|\s*(?:date|year)\s*=\s*(20)\d)(\d)(?=*)/gi, "$1–$2$3")
		.ohc_regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*\s*@YYNN(?=*)/gi, "$1@YYYY1–@YYYY2") // common cs1 error(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*\s*@YYYY(?=*)/gi, "$1@YYYY1–@YYYY2") //common cs1 error
		.replace(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1\d|20)\d)(?=*)/gi, "$1S$2 $3") // common cs1 error
		.replace(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1\d|20)\d)(?=*)/gi, "$1A$2 $3") // common cs1 error
		.replace(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1\d|20)\d)(?=*)/gi, "$1F$2 $3") // common cs1 error
		.replace(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1\d|20)\d)(?=*)/gi, "$1W$2 $3") // common cs1 error
		.replace(/(\|\s*(?:date)\s*=)\s*(Spring|Summer|Autumn|Fall|Winter)(S(?:pring|ummer)|Autumn|Fall|Winter) ?/gi, "$1$2–$3 ") // common cs1 error
		.ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=*)/gi, "$11 $2") //common cs1 error
		//.ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=*)/gi, "$1@Year") // common cs1 error
		//.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=*)/gi, "$1c. @Year") // common cs1 error
		//.ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=*)/gi, "$1c. $2") // common cs1 error
		.ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1\d{2}|2000)(?=*)/gi, "$1") // rem access date before Misplaced Pages (January 2001)
		.ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1\d{2}|2000)(?=*)/gi, "$1") // rem access date before Misplaced Pages (January 2001)
		.ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:April|June|September|November) @year)(?=*)/gi, "$130$2") // rem nonsense access date (short months)
		.ohc_regex(/(\|\s*access-?date\s*=)\s*29( February (?:200|201))(?=*)/gi, "$128$2") // rem nonsense access date 29 Feb (non-leap year)
		.ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3)( February @yyyy)(?=*)/gi, "$128$2") // rem nonsense access dates February
		.replace(/(\|\s*access-?date\s*=)\s*(\d{4})(?=*)/gi, '') // common cs1 error

		// month+day+year pseudo-ISO dates
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY")

		.replace(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date)(?=*)/gi, "$1n.d.") // common cs1 error
		.replace(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=*)/gi, "$1n.d.") // common cs1 error
		.replace(/(\|\s*)year(\s*=\s*)(?=n\.?d\.)(?=*)/gi, "$1date$2") // common cs1 error

		// remove parasitic metadata -  days of the week/descriptives
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:*|)@Day\s+@Month\s+@YYYY((?:\b|)\s?)*(?=*)/gi, "$1@Day @Month @YYYY$2") // rem negate "<", "hyphens" "dashes" 26/6/2020
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)*@Month\s+@Day,\s+@YYYY((?:\b|)\s?)*(?=*)/gi, "$1@Month @Day, @YYYY$2") // rem negate "<", "hyphens" "dashes" 26/6/2020
		//.ohc_regex(/(\|\s*date\s*=\s*)(?:*\D|)@Day\s+@Month\s+@YYYY ?– ?@Day\s+@Month\s+@YYYY*(?=*)/gi, "$1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year2")
		//.ohc_regex(/(\|\s*date\s*=\s*)*@Month\s+@Day,\s+@YYYY ?– ?@Month @Day, @YYYY*(?=*)/gi, "$1@Mon1 @Day1, @Year1 – @@Mon2 Day2, @Year2")
		//.replace(/(\|\s*author\s*=\s*)(?:posted|published)(?: by\b| on\b|)(?=\w)/gi, "$1")
		//.replace(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=\s*)(?:accessed|retrieved|entered|posted|published|(?:last |)updated?|©)(?: by\b| on\b|)*(?=\w)/gi, "$1")
		.replace(/(\|\s*(?:author|first|last)\s*=\s*)(?:by\b|on\b)*(?=\w)/gi, "$1")
		.replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1")
		.replace(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)?\s/gi, "$1") // rem "Sun" - false positives

		// remove deprecated parameters (|day= and |month)
	 	.ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=)/gi, "$1date=@Day @Month @Year")
	 	.ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=)/gi, "$1date=@Month @Day, @Year")

		// typos
		.ohc_regex(/(date *= *)@Day @Month ?@th/gi, "$1@Day @Month")
		.ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, "$1@Day @Month")

		.ohc_regex(/(date *= *(?:?\d|30|31) )(Jan|Febr)?{3,4}\w{0,2}(?= (?:1\d|20)\d\b)/gi, "$1$2uary")
		.ohc_regex(/(date *= *(?:?\d|30|31) )J{3,5}r\w{0,2}(?= (?:1\d|20)\d\b)/gi, "$1January")
		.ohc_regex(/(date *= *(?:?\d) )Febua?r\w{0,2}(?= (?:1\d|20)\d\b)/gi, "$1February")
		.ohc_regex(/(date *= *(?:?\d|30|31) )M\w{2,3}ch(?= (?:1\d|20)\d\b)/gi, "$1March")
		.ohc_regex(/(date *= *(?:?\d|30) )A\w{2,3}l\w?(?= (?:1\d|20)\d\b)/gi, "$1April")
		.ohc_regex(/(date *= *(?:?\d|30|31) )Ma(?= (?:1\d|20)\d\b)/gi, "$1May")
		.ohc_regex(/(date *= *(?:?\d|30) )J\wn\w(?= (?:1\d|20)\d\b)/gi, "$1June")
		.ohc_regex(/(date *= *(?:?\d|30) )J\w{1,2}e(?= (?:1\d|20)\d\b)/gi, "$1June")
		.ohc_regex(/(date *= *(?:?\d|30|31) )Jul\w{1,2}(?= (?:1\d|20)\d\b)/gi, "$1July")
		.ohc_regex(/(date *= *(?:?\d|30|31) )A{2,3}\w{1,4}t(?:\w|us)?(?= (?:1\d|20)\d\b)/gi, "$1August")
		.ohc_regex(/(date *= *(?:?\d|30|31) )(Sept|Nov|Dec)\w{2,4}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, "$1$2ember")
		.ohc_regex(/(date *= *(?:?\d|30) )S\w{0,2}p?\w{2,5}{2,3}\w?(?= (?:1\d|20)\d\b)/gi, "$1September")
		.ohc_regex(/(date *= *(?:?\d|30|31) )O\w{0,2}t\w{1,3}{2,3}\w?(?= (?:1\d|20)\d\b)/gi, "$1October")
		.ohc_regex(/(date *= *(?:?\d|30) )\w{1,2} ?\w{1,3}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, "$1November")
		.ohc_regex(/(date *= *(?:?\d|30|31) )D? ?\w{1,4}b{1,2}\w?(?= (?:1\d|20)\d\b)/gi, "$1December")

		.ohc_regex(/(date *= *)@Month\w(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1@Month") //rem stray digit at the end of year string

		.ohc_regex(/(date *= *)(Jan|Febr)?{3,4}\w{0,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1$2uary")
		.ohc_regex(/(date *= *)J{3,5}r\w{0,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1January")
		.ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:?\d),?|) (?:1\d|20)\d\b)/gi, "$1February")
		.ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1March")
		.ohc_regex(/(date *= *)A\w{2,3}l\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1April")
		.ohc_regex(/(date *= *)Ma(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1May")
		.ohc_regex(/(date *= *)J\wn\w(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1June")
		.ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1June")
		.ohc_regex(/(date *= *)Jul\w{1,2}(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1July")
		.ohc_regex(/(date *= *)A{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1August")
		.ohc_regex(/(date *= *)(Sept|Nov|Dec)\w{2,4}b{1,2}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1$2ember")
		.ohc_regex(/(date *= *)S\w{0,2}p?\w{2,5}{2,3}\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1September")
		.ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}{2,3}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1October")
		.ohc_regex(/(date *= *)\w{1,2} ?\w{1,3}b{1,2}\w?(?=(?: (?:?\d|30),?|) (?:1\d|20)\d\b)/gi, "$1November")
		.ohc_regex(/(date *= *)D? ?\w{1,4}b{1,2}\w?(?=(?: (?:?\d|30|31),?|) (?:1\d|20)\d\b)/gi, "$1December")

		// insert comma to separate date from army unit
		.ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1")

		// remove parasitic metadata - time
		.ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T\d:\d:\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|{1,2}T\s*|Z))(?=\s*)/g, "$1")
		.ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
		.ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
		.ohc_regex(/(\|\s*\w*date\s*=\s*\w+@month @day,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
		.ohc_regex(/(\|\s*\w*date\s*=\s*\w+@day @month,? @yyyy)\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|))(?=\|)/g, "$1")
		.ohc_regex(/(\|\s*\w*date\s*=*)\s?(?:T?\d:\d:\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|{1,2}T\s*|Z))/g, "$1")

		// add back spaces or comma or remove other single artefact after date string
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Day\s{,2}@Month\s{,2}@YYYY?(?=\s*)/gi, "$1@Day @Month @YYYY$2")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month\s{,2}@Day,?\s{,2}@YYYY?(?=\s*)/gi, "$1@Month @Day, @YYYY$2")

		// long-hand palliative for observed failure to insert spaces
		.ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)(?\d|30|31)\s*(January|February|March|April|May|June|July|August|September|October|November|December)\s*((?:19\d|20)\d\s?)*(?=\s*)/gi, "$1$2 $3 $4")
		//.ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Day\s*@Month\s*@YYYY(\s?|\s?)\w**(?=)/gi, "$1@Day @Month @YYYY$2")
		//.ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Month\s*@Day,\s*@YYYY(\s?|\s?)\w**(?=)/gi, "$1@Month @Day, @YYYY$2")

		// remove extraneous bracket //from Batty
		.ohc_regex(/{{(\s*it(?:e|ation))(+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)(+)\](?=\s*)/gi, "{{$1$2$3$4")

		// fix bda template redirect
		//.replace(/\{\{bda\|(+)\}\}/gi, "{{birth date and age|$1}}")
		//.replace(/\{\{dda\|(+)\}\}/gi, "{{death date and age|$1}}")

		// zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
		//.replace(/({{(?:end|start)date)\|df=y(?:es|)/gi, "$1") // rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
		.ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:*)}}/gi, "@Day @Month @YYYY")
		.replace(/{{#formatdate:(+)}}/gi, "$1")
		.replace(/\{\{#dateformat:(+)(?:\|dmy|\|mdy)?\}\}/gi, "$1")
		//.ohc_regex(/(date*=*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, "$1@Month @DD, @YYYY") // stripping start/end template notes inside "|date=" parameter (line 72)
		.ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:{3}|iso)|)}}/gi, "@Day @Month @YYYY")
		.ohc_regex(/\|\s*(?:archive|access|air)-?date\s*=\s*\{\{date\}\}(?=\s*)/gi, "")   //remove {{date}} template without parameters that inappropriately return crrent date
		.ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@YYYY-@MM-@DD")
		.ohc_regex(/\{\{date\|@YYYY\/@MM\/@DD\}\}/gi, "@YYYY-@MM-@DD") //remove {{date}} template while rectifying slash dates within the template
		.ohc_regex(/\{\{date\|(@DD@Mon|@Mon@DD)\}\}/gi, "@Day @Month")
		.replace(/\{\{date\|(+)(?:\|l?(?:{3}|iso|none|link))?\}\}/gi, "$1")
		.ohc_regex(/*\{\{accessdate\|@YYYY-@MM-@DD*\}\}/gi, " Retrieved @YYYY-@MM-@DD")
		.ohc_regex(/*\{\{retrieved*\|accessdate=(*)\}\}/gi, " Retrieved $1")
		//.ohc_regex(/(date*=*|\w{2,}*)\{\{(?:start|end).date*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, "$1@YYYY")  // stripping start/end template (disabling to placate Pigsonthewing)
		//.ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, "@Month @YYYY")  // tripping start/end template notes
		//.ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, '')  // stripping start/end template notes
		.ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")

		// expand one and two-digit years in ranges
		.replace(/(\()@Month @YYYY@Month @YYNN(\))/gi, "$1@Month1 @YYYY1 – @Month2 @YYYY2$2")
		.replace(/(\(1)(\d)(1)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(2)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(3)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(4)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(5)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(6)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(7)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(1)(\d)(8)(9\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(1)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(2)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(3)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(4)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(5)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(6)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(7)(\))/gi, "$1$2$3–$2$4")
		.replace(/(\(20)()(8)(9\))/gi, "$1$2$3–$2$4")

		.ohc_regex(/(\W)@DD@th?, @DD@th?((?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;))@DD@th?(?:\sof\s?)?(|&nbsp;)@Month(?=\W)/gi, "$1@Day1, @Day2$2@Day3$3@LMonth")
		.ohc_regex(/(\W)@DD@th?((?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;))@DD@th?(?:\sof\s?|)(|&nbsp;)@Month(?=\W)/gi, "$1@Day1$2@Day2$3@LMonth")
		.ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, "$1@Day @LMonth @YYYY")
		.ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, "$1@Day @LMonth")
		.ohc_regex(/(\W)@Day@th?(?:\sof|)(|&nbsp;|{{(?:break|nbsp)}})@Month(?=\w])/gi, "$1@Day$2@LMonth")
		.ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: |&nbsp;)@DD@th?(\s(?:and|&|to|or)(?:|&nbsp;))(?:the\s)?@DD@th?(?=\w])/gi, "$1@LMonth @Day1, @Day2$2@Day3")
		.ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:|&nbsp;)|\sof\s)?(\d{3,4}\W\D)/gi, "$1$2 $3$4$5@Day, $6")
		.ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, "$1$2 $3$4$5@Day")
		.ohc_regex(/(\W)@Month(|&nbsp;|{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, "$1@LMonth$2@Day, @Year")
		.ohc_regex(/(\W)@Month @Day(?:\sof|,|)(|&nbsp;|{{(?:break|nbsp)}})@Year(?=\w])/gi, "$1@Month @Day,$2@Year")

		// consolidating/amalgamating date fields
		.ohc_regex(/(\|*date*=*@day)\s*\|*month=*(@month)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2 $3")
		.ohc_regex(/(\|*date*=*@day.?@month)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2")
		.ohc_regex(/(\|*date*=*@month.?@day)\s*\|*year=*(@yyyy*)(?=)/gi, "$1 $2")

		// eliminating dates and time placed in author parameter
		// removing artefacts from Indian news sites (TNN Aug 30, 2012, 05.46AM)
		.ohc_regex(/(\|\s*author\s*=\s*(?:{2,3}\b))(?:*)\d{4}, {4,5}(&nbsp;|)M IST(?=*\|)/g, "$1$2")
		//.ohc_regex(/(\|\s*author=(?:|{}]*))(TNN|PTI) @day @month @yyyy, {4,5}(&nbsp;|)M IST(?=*\|)/g, "$1$2")

		.ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|)|)(?=\|)/g, "$1")
		.ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? ?\d\d(?:\s*|&nbsp;)(?:\s*|)(?:GMT\s*|UTC\s*|{1,2}T\s*|)|)(?=\|)/g, "$1")
		.ohc_regex(/(\|\s*author\s*=\s*\w+)@month @day,? @yyyy(?:|{}]*)(?=)/g, "$1")
		.ohc_regex(/(\|\s*author\s*=\s*\w+)@day @month,? @yyyy(?:|{}]*)(?=)/g, "$1")
		.ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)@dd-@mm-@yyyy/gi, "$1")
		.ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)@YYYY-@MM-@DD ?/gi, "$1")
		.replace(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w+)?)\d:\d(?:|&nbsp;)?(?:m|\.m\.|)(?: ?(?:{1,2}T|UTC)?|)/gi, "$1")
		//.ohc_regex(/(\|\s*author\s*=\s*(?:\w+)?)\s*\d\d(?:\d|)/gi, "$1") //let's see later if we need this

		// eliminating mm-dd-yyyy dates
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM(1|2\d|3)@YYYY/gi, "$1@Month $2, @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Mon(1|2\d|3)@YYYY/gi, "$1@Month $2, @YYYY")
		.ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@MM(1|2\d|3)@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY")
		//.ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY")

		.ohc_regex(/()@Mon(1|2\d|3)@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@Mon\/(1|2\d|3)\/@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@Mon\.(1|2\d|3)\.@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@Mon (1|2\d|3) @YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@MM(1|2\d|3)@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@MM\/(1|2\d|3)\/@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@MM\.(1|2\d|3)\.@YYYY(?=)/gi, "$1@Mon $2, @YYYY")
		.ohc_regex(/()@MM (1|2\d|3) @YYYY(?=)/gi, "$1@Mon $2, @YYYY")

		// eliminating dd-mm-yyyy dates (assumed default)
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@MM@YYYY/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@Mon@YYYY/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@DD@MM@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY")
		.ohc_regex(/(?:Accessed|Retrieved)(?:(?: online|) on|:?)@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY")
		.ohc_regex(/()@DD@Mon@YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD\/@Mon\/@YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD\.@Mon\.@YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD @Mon @YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD@MM@YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD\/@MM\/@YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD\.@MM\.@YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/()@DD @MM @YYYY(?=)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD@Month@YYNN(?=\s*)/gi, "$1@Day @Month @YYYY")

		//convert yyyy-dd-mm to yyyy-mm-dd
		.ohc_regex(/{{(\s*it(?:e|ation))(+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1|20)\d{2})(1|2\d|3)(0?\d|1)(\s*)/gi, "{{$1$2$3-$5-$4$6") // from Batty

		// eliminating other errant formats
		.ohc_regex(/(\|(?:*)date\s*=\s*)(?\d|30|31) @Month \2,? @YYYY(?=\s*)/gi, "$1$2 @Month @YYYY") //repeated digits
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day ?@Month ?200(\d)?(?=\s*)/gi, "$1@Day @Month 20$2")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month ?@Day,? ?200(\d)?(?=\s*)/gi, "$1@Month @Day, 20$2")

		.ohc_regex(/(\()@DD-@MM-@YYYY(\)\W)/gi, "$1@Day @Month @YYYY$2")
		.ohc_regex(/(\()@DD-@Month-@YYYY(\)\W)/gi, "$1@Day @Month @YYYY$2")
		.ohc_regex(/(\|(?:*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/(\|(?:*)date\s*=\s*)@DD @Month,? @YYYY(?=\s*)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*)/gi, "$1@Day @Month @YYYY")
		.ohc_regex(/\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)")
		.ohc_regex(/\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)")
		.ohc_regex(/\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)")
		.ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY,? @Month(?=\s*)/gi, "$1@Month @YYYY")
		.ohc_regex(/\(@YYYY, @Month\)/gi, " (@Month @YYYY)")
		.ohc_regex(/\(@Mon@YYYY\)/gi, " (@Mon @YYYY)")

		// CS1 errors ISO-like dates (too few or too many digits)
		.ohc_regex(/(date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@YYYY-@ZM-@ZD") //ndashes and emdashes
		.ohc_regex(/(\|\s*access-?date\s*=)\s*@YYYY-0@DD(?=\s*)/gi, "") //rem nonsense access date
		.ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY@MM@DD(?=\s*)/gi, "$1@YYYY-@ZM-@ZD") //ndashes and emdashes
		//.ohc_regex(/(\|(?:*)date\s*=\s*)@YYYY@MM(?=\s*)/gi, "$1@Month @YYYY") //transform "yyyy-mm" to "month year"
		.ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3")
		.ohc_regex(/(<ref*>+?)()@YYYY@MM()(*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4")

		// spaces and commas between month and year
		.ohc_regex(/@Month(?:,?|\s+of|)(\s|&nbsp;)@YYYY(?=\D)/gi, "@LMonth$1@YYYY")

		// fix month names (capitalize, remove dots)
		.ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2")
		.ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2")
		.ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2")
		.ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2")
		.replace(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=*(=|BC|AD|CE))/g, "$1c$2")
		//.replace(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?!\w*|''|")/g, "$1c$2")

		//spaces and commas - in date formats
		.ohc_regex(/(\D\W\+(@month)(\]\])?*,*(\?\]?\W\D)/gi, "$1 $2$3 $4")
		.ohc_regex(/(\D\W\+(@dd)(\]?\]?)(?:*,*)(\?\]?\W\D)/gi, "$1$2 $3$4, $5")
		.ohc_regex(/(\D\W\+(@dd)(\]?\]?)+(\?\]?\W\D)/gi, "$1$2 $3$4, $5")

		.ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2") //repeat after delinking

		// spaces and commas - md-md and dm-dm date ranges
		.ohc_regex(/(\D\W)@Month\s@DD(&nbsp;|\s)(?:|&dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2")
		.ohc_regex(/(\D\W)@Month\s@DD(?:|&dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2")
		.ohc_regex(/(\D\W)@DD\s@Month(&nbsp;|\s)(?:|&dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2")
		.ohc_regex(/(\D\W)@DD\s@Month(?:|&dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2")

		// spaces and commas - d-dm and md-d date ranges
		.ohc_regex(/(\D\W)@Month(\s|&nbsp;)@DD@th?(?:(?:\s*|&nbsp;|)(?:\s*|&nbsp;|))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2")
		.ohc_regex(/(\D\W)@DD@th?(?:(?:\s*|&nbsp;|)(?:\s*|&nbsp;|))@DD@th?(\s|&nbsp;)@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1")

		// spaces and commas between month and year (again)
		.ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
}

/** ------------------------------------------------------------------------- */
/// ISO to long format

function ohc_ISO_to_dmy_in_citations(editor) {
	editor
		// ISO dates within single citation
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
}

function ohc_ISO_to_mdy_in_citations(editor) {
	editor
		// ISO dates within single citation
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi,  "$1@Month @Day, @YYYY");
}

function ohc_ISO_to_dmy_in_references(editor) {
	editor
		// multiple calls for multiple dates within single citation
		.ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3")
		.ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
}

function ohc_ISO_to_mdy_in_references(editor) {
	editor
		// multiple calls for multiple dates within single citation
		.ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3")
		.ohc_regex(/(<ref*>+?)()@YYYY@MM@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
}

// currently unused
function ohc_ISO_to_dmy_anywhere(editor) {
	editor
		// multiple calls for multiple dates within single citation
		.ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Day @Month @YYYY$2")
		.ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Day @Month @YYYY$2")
		.ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Day @Month @YYYY$2");
}

// currently unused
function ohc_ISO_to_mdy_anywhere(editor) {
	editor
		// multiple calls for multiple dates within single citation
		.ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Month @Day, @YYYY$2")
		.ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Month @Day, @YYYY$2")
		.ohc_regex(/()@YYYY@MM@DD()/gi, "$1@Month @Day, @YYYY$2");
}

function ohc_delink_ISO_to_dmy(editor) {
	ohc_ISO_to_dmy_in_citations(editor);
	ohc_ISO_to_dmy_in_references(editor);

	editor
		.replace(/()@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, "$1@Day @Month @Year$2")
		.ohc_regex(/(\|\|*)@YYYY@MM@DD(*\|\|)/gi, "$1{{dts|format=dmy|@YYYY|@MM|@DD}}$2")  // dts template for sortable tables
		.ohc_regex(/(\{\{dts\|format=)mdy\|/gi, "$1dmy|");  //flip dts template formats
}

function ohc_delink_ISO_to_mdy(editor) {
	ohc_ISO_to_mdy_in_citations(editor);
	ohc_ISO_to_mdy_in_references(editor);

	editor
		.replace(/()@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, "$1@Month @Day, @Year$2")
		.ohc_regex(/(\|\|*)@YYYY@MM@DD(*\|\|)/gi, "$1{{dts|@YYYY|@MM|@DD}}$2")  // dts template for sortable tables (mdy is default)
		.ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, "$1");  // flip dts template formats
}

function ohc_delink_year_in_X(editor) {
	editor
		//.ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1") // disabled 3/5/21 discussion at https://en.wikipedia.org/search/?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox?
		//.ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1")
		.ohc_regex(/\]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, "$1")
		.replace(/\\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, "$1")

		.replace(/\\]/gi, "$1$2");
}


// format parameter must be 'dmy' or 'mdy'
function ohc_fix_dts_template(editor, format) {
	editor
		// dts - format=dmy in this case (per D12000)
		// per {{dts}} doc, remove the obsolete link=off param
		.replace(/(\{\{dts*)(?:\|link=off)/gi, "$1")
		.ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, "$1"+format+"$2")
		.ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, "$1"+format+"$2")
		.ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, "$1|format="+format+"$2")

		// stripping – {{dts}} serves no purpose inside date parameters
		.ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*(*)\}\}(?=\s*)/gi, "$1$2")
		.ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*(*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*)/gi, "$1$2")
		.ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*)/gi, "$1@YYYY-@MM-@DD ")
		.ohc_regex(/(\|(?:*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*)/gi, "$1@YYYY-@MM-@DD ");
}

// format parameter must be 'dmy' or 'mdy'
function ohc_fix_gr_template(editor, format) {
	editor
		// GR - date formatting parameter
		// per {GR} doc, insert date formatting param
		.replace(/(\{\{GR\|\d\d?)(?!\|date)/gi, "$1|dateform=" + format);
}

function ohc_dates_to_dmy(editor) {
	editor
		.replace(/\|df={3}(?:-all|)(?=\s*)/gi, '')
		.replace(/\|format=mdy/gi, "|format=dmy")

		// change start and end templates; vgrelease new v=2 or mdy is default
		.replace(/(\{\{(?:start date|end date)*\|)df=ye?s?\|(*df=ye?s?)/gi, "$1$2")
		.replace(/(\{\{vgrelease new*\|)(?:v=1\||)({2,3}\|)/g, "$1v=2|$2")
		.ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Day @Month @YYYY") // spotted at ]

		// change birth and death templates
		.replace(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)*\|)m(f=ye?s?)/gi, "$1d$2") // substitute df for mf
		.replace(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)+)(\}\})/gi, "$1|df=y$2") // insert df parameter
		.replace(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)+\|)df=ye?s?\|(*df=ye?s?)/gi, "$1$2") // put date format parameter at the end
		.replace(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1|20)\d{2}\}\})/gi, "$1$2")  // date format parameter not needed – year only

		// convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
		.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4")
		.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth")

		//.ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth") //disabling as unlikely and ungrammatical constructions causing false positives

		//'md, md,' to 'dm, dm,'
		.ohc_regex(/(\D\W)@Month @Day, @Month @Day(?=\W\D)/gi, "$1@Day1 @LMonth1, @Day2 @LMonth2")

		//convert simple mdy dates to dmy
		.ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth")
		.ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2")
		.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year")
		.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth")

		//Month+day_number " 7th March" -> "7 March"
		.ohc_regex(/(\D\W)@Day\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year")
		.ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth")
		.ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year")

		//dates with embedded nbsp
		.ohc_regex(/(\D\W)@Month(|&nbsp;)(\d{1,2},(?: |&nbsp;)\d{1,2}(?:\s(?:and|&|to|or)(?:|&nbsp;))\d{1,2})(?=\w])/gi, "$1$3$2@LMonth ")
		.ohc_regex(/(\D\W)@Month(|&nbsp;|{{(?:break|nbsp)}})@Day,(|&nbsp;|{{(?:break|nbsp)}})@YYYY(?=\w])/gi, "$1@Day$2@Month$3@Year")

		//remove comma
		.ohc_regex(/(\D\W)@Day\s@Month,\s?@Year(?=\W\D)/gi, "$1@Day @LMonth @Year")

		//	remove "the" from "on the dd month"
		.ohc_regex(/(on |by )the @Day\s@Month(?=)/gi, "$1@Day @LMonth")

		//remove space from date range conversion
		.ohc_regex(/(\D ) @Day(\/|\s?(?:|&ndash;)\s?|(?:|&nbsp;)(?:and|&|to|or)(?:|&nbsp;)+?)/gi, "$1@Day$2");
}

function ohc_dates_to_mdy(editor) {
	editor
		// change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default
		.replace(/\|df={3}(?:-all|)(?=\s*)/gi, '')
		.replace(/\|df=y(?:es|)(?=)/gi, '')
		.replace(/(mf=y(?:es|)\|*\|)(?:mf=y(?:es|)\|)/gi, "$1")
		.replace(/(\{\{vgrelease new*\|)(?:v=2\||)({2,3}\|)/g, "$1$2")
		.ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY@MM@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY")

		// convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d)
		.ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY")
		.ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2")
		//.ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY") // disabling as unlikely and ungrammatical constructions causing false positives
		//.ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2") // disabling as unlikely and ungrammatical constructions causing false positives

		// 'dm, dm,' to 'md, md,'
		.ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2")

		// convert simple dmy dates to mdy
		.ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day")
		.ohc_regex(/(\D\W)@Day(\s|&nbsp;)@Month,?(\s|&nbsp;)@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year")
		.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year")
		.ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day+@Month(?=\W\D)/gi, "$1@LMonth @Day")

		// Month+day_number "March 7th" -> "March 7"
		.ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY")
		.ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month(\s|&nbsp;)@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY")
		.ohc_regex(/(\D\W)@Month(\s|&nbsp;)@Day(?=\W\D)/gi, "$1@LMonth$2@Day")
		.ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month()(?=\W\D)/gi, "$1@LMonth$2@Day$3")

		// add comma where missing
		.ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s\w)/gi, "$1@LMonth @Day, @YYYY,")

		// rem superfluous comma where applicable
		.ohc_regex(/(\D)@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
}

function ohc_fix_dmy_redundancies(editor) {
	editor
		// month-range redundancies (repeating month names)
		.ohc_regex(/(@dd)@th? @Month{1,2}((?:to|and|-|–){1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) {
			if (d1.m == d2.m) return true;
			return false;
		});
}

function ohc_fix_mdy_redundancies(editor) {
	editor
		// month-range redundancies (repeating month names)
		.ohc_regex(/(@Month{1,2}@dd)@th? (to|and|-|–){1,2}@Month{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) {
			if (d1.m == d2.m) return true;
			return false;
		});
}

function ohc_expand_ref_dates(editor) {
	editor
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*)/gi, "$1@FullMonth @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*)/gi, "$1@Day @FullMonth @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*)/gi, "$1@FullMonth @Day, @YYYY")

		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=\s*)/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=\s*)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=\s*)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=\s*)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY")
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=\s*)/gi, "$1@$2 – @FullMonth @YYYY")

		.ohc_regex(/(<ref*>(?:+?|))((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2")
		.ohc_regex(/(<ref*>(?:+?|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY")
		.ohc_regex(/(<ref*>(?:+?|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY")
		.ohc_regex(/(<ref*>(?:+?|))@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=(?:*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY")
		.ohc_regex(/(<ref*>(?:+?|))((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=(?:*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY");
}

function ohc_expand_all_dates(editor) {
	editor
		.ohc_regex(/()@Month @YYYY(?=)/gi, "$1@FullMonth @YYYY")
		.ohc_regex(/()@Day @Month @YYYY(?=)/gi, "$1@Day @FullMonth @YYYY")
		.ohc_regex(/()@Month @Day, @YYYY(?=)/gi, "$1@FullMonth @Day, @YYYY")

		.ohc_regex(/()((?:?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:?\d|30|31) |)@Month @YYYY(?=)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2")
		.ohc_regex(/()@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY")
		.ohc_regex(/()@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY")
		.ohc_regex(/()@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY")
		.ohc_regex(/()((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=)/gi, "$1$2 – @FullMonth @YYYY")

		.ohc_regex(/(\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*)/gi, "$1@Day @FullMonth @YYYY")
		.ohc_regex(/(\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*)/gi, "$1@FullMonth @Day, @YYYY")
		.ohc_regex(/(\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2")
		.ohc_regex(/(\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2")
		.ohc_regex(/(\((?:c\. |))@YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2")
		.ohc_regex(/(\((?:c\. |))@Month ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY")
		.ohc_regex(/(\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY");
	}

function ohc_abbrev_ref_dates(editor) {
	editor
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*)/gi, "$1@Day @Mon @YYYY")
		.ohc_regex(/(<ref*>(?:+?|))(?\d|30|31) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il||ust|(?:t?em|o)ber)( (?:19\d|20)\d)(?=(?:*?|)<\/ref>)/gi, "$1$2 $3$4")
		.ohc_regex(/(\()@Day @Month @YYYY()/gi, "$1@Day @Mon @YYYY$2")

		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*)/gi, "$1@Mon @Day, @YYYY")
		.ohc_regex(/(<ref*>(?:+?|))(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:r?uary|ch|il||ust|(?:t?em|o)ber) (?\d|30|31),( (?:19\d|20)\d)(?=(?:*?|)<\/ref>)/gi, "$1$2 $3,$4")
		.ohc_regex(/()@Month @Day, @YYYY()/gi, "$1@Mon @Day, @YYYY$2");
}

//not currently used
function ohc_abbrev_all_dates(editor) {
	editor
		.ohc_regex(/()@Day @Month @YYYY(?=)/gi, "$1@Day @Mon @YYYY")
		.ohc_regex(/()@Month @Day, @YYYY(?=)/gi, "$1@Mon @Day, @YYYY");
}

//not currently used
function ohc_dmy_publication_dates(editor) {
	editor
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY") // conversion of dates in references outside of the protection loop (eg for quotations etc.)
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Day @Month @YYYY")

		// replace ISO dates (within parentheses) only within refs
		.ohc_regex(/(<ref*>+?)(\()@YYYY-@MM-@DD(\))(\W*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
}

function ohc_mdy_publication_dates(editor) {
	editor
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY") // conversion of dates in references outside of the protection loop (eg for quotations etc.)
		.ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\\]\)@MM@DD(?:\]\])?(?=\s*)/gi, "$1@Month @Day, @YYYY")

		// replace ISO dates (within parentheses) only within refs
		.ohc_regex(/(<ref*>+?)(\()@YYYY-@MM-@DD(\))(\W*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
}

function ohc_Bigendian_ref_dates(editor) {
	editor
		// Add a tag to the summary box
		.replace(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|+\}\})/gi, "$1|cs1-dates=y$2");
}

/** ------------------------------------------------------------------------ **/
/// EDIT SUMMARIES & USE DMY TEMPLATE
// this function modified 2019-03-27 from ]
// format parameter must be 'dmy' or 'mdy'
function ohc_use_dates_template(editor, format) {
	// current month-year
	var currentDate = new Date();
	var currmonth = currentDate.getMonth();
	var curryear = currentDate.getFullYear();
	var myMonths = ;
	var curryyyymm = myMonths + " " + curryear;

	// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument
	editor
		// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
		.replace(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *()/gi, "{{Use " + format + " dates$1")

		// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
		.replace(/\{\{ *use *(?:dmy|mdy) *()/gi, "{{Use " + format + " dates$1")

		// strip leading / trailing whitespace from 'use xxx dates'
		.replace(/\{\{ *use (?:dmy|mdy) dates *()/gi, "{{Use " + format + " dates$1");

	// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
	var rxpdd = new RegExp("{{Use " + format + " dates", "gi");	// here we search for canonical form {{use xxx dates}} that has current date
	var dflagfound = editor.get().search(rxpdd);
	if (dflagfound === -1) {
		editor.prepend("{{Use " + format + " dates|date=" + curryyyymm + "}}\r\n");	// not found so insert new template at top of wikitext
		return;																	    // and done
	}

	// step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is
	editor
		.replace(/(\{\{use (?:dmy|mdy) dates)\| *date *=*\| *cs1\-dates *= *(*?) *\}\}/gi, "$1|date=" + curryyyymm + "|cs1-dates=$2}}")	// with |date= followed by |cs1-dates=
		.replace(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *(*?) *\| *date *=*\}\}/gi, "$1|date=" + curryyyymm + "|cs1-dates=$2}}")	// with |cs1-dates= followed by |date=
		.replace(/(\{\{use (?:dmy|mdy) dates)\| *date *=*\}\}/gi, "$1|date=" + curryyyymm + "}}")											// with |date=
		.replace(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *(*?) \}\}/gi, "$1|date=" + curryyyymm + "|cs1-dates=$2}}")					// with |cs1-dates
		.replace(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, "$1|date=" + curryyyymm + "}}")																// no parameters so add |date=curryyyymm
		.replace(/(\{\{*use+(?:dmy|mdy)+dates*\}\})(*)(\{\{*short description*\}\})/gi, "$3$2$1");		// repositioning "short description" template at the top
}



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

var linkmap = ;

function ohc_protect_dates(editor) {
	// 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;
	};

	editor
		// \|x=
		.replace(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function)
		.replace(/(<!--)(*?)(-->)/gi, protect_function)
		.replace(/(<math>)(*?)(<\/math>)/gi, protect_function)
		.replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function)
		.replace(/(<ref)(+)(>)/gi, protect_function)
		.replace(/((?:Category|Image|File):)(]*)(])/gi, protect_function)
		.replace(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function)
		.replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{(?:harvnb|r|wikisource)\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{(?:Canadian federal by-election))(+)(\}\})/gi, protect_function)

		.replace(/(\]*)(\])/gi, protect_function)
		.replace(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function)
		.replace(/(\|archive-?url=https?:|ftp:)(*)(\|)/gi, protect_function)  //repurposed unused line to protect archive url links (archive.today)
		.replace(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function)
		.replace(/(<noinclude>)(*?)(<\/noinclude>)/gi, protect_function)
		.replace(/(<gallery)(*?)(<\/gallery>)/gi, protect_function)
		.replace(/(<poem>)(*?)(<\/poem>)/gi, protect_function)
		.replace(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function)
		.replace(/((?:image\d?|image_skyline|imagelocation\d?|imagename|imagefile|img|map\d|pic)\s*=)(*)()/gi, protect_function)
		.replace(/(\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)
		.replace(/(\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)
		.replace(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function)
		.replace(/(\s*(?:)\s*=)(\s*+\s*)(\|)/gi, protect_function)
		.replace(/(\{\{navsource\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{merge(?:+))(+)(\})/gi, protect_function)
		.replace(/(\{\{(?:singlechart)\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{(?:defaultsort|graph):)(+)(\})/gi, protect_function)
		.replace(/()(*)()/gi, protect_function)
		.replace(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function)
		.replace(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function)
		.replace(/(\\]|\|)/gi, protect_function)

		// retraining redirects containing a date
		.replace(/(\\]|\|)/gi, "$1Jiusan Society$2")
		.replace(/(\\]|\|)/gi, "$1Tiananmen Square protests of 1989$2")
		.replace(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")
		.replace(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")

		// protect alternate meanings of 'may' and 'march' (note: not case insensitive)
		//.ohc_regex(/()(@day,?\s{0,3}may)()/g, protect_function)  //disabled 26 May – not case senstitve: false negatives in converting dates in May
		.ohc_regex(/()(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function)

		// protect all links containing a date and some text
		.ohc_regex(/(\\|\n]+?@day\|\n]+?@fullmonth\|\n]*)(\]\]|\|)/gi, protect_function)
		.ohc_regex(/(\\|\n]*?@day\|\n]+?@fullmonth(?:,? @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)
		.ohc_regex(/(\\|\n]+?@fullmonth\|\n]+?@day\|\n]*)(\|)/gi, protect_function)
		.ohc_regex(/(\\|\n]*?@fullmonth\|\n]+?@day(?:, @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)

		// protects certain dates
		.replace(/(\)/gi, protect_function)
		.replace(/()(March (?:8|14) Alliance)()/gi, protect_function)
		.replace(/()(23rd March 1931: Shaheed)()/gi, protect_function)
		.replace(/()(Long March )()/gi, protect_function)
		.replace(/()(National September 11 Memorial & Museum)()/gi, protect_function)
		.replace(/()(Queen Elizabeth II September 11th Garden)()/gi, protect_function)
		.replace(/()(Bombay March 12)()/gi, protect_function)
		.replace(/()(movement 2 June)()/gi, protect_function)
		.replace(/()(6th\sof October City)()/gi, protect_function)
		.replace(/()(Party Workers' Liberation Front 30th of May)()/gi, protect_function)
		.replace(/()(4th\sof August regime)()/gi, protect_function)
		.replace(/()(19th\sof April movement)()/gi, protect_function)
		.replace(/()(June 4th (?:incident|museum))()/gi, protect_function)
		.replace(/()(The Battle Of Marston Moor \(July 2nd,? 1644\))()/gi, protect_function)
		.replace(/()(Night of January 16th)()/gi, protect_function)
		.replace(/()(Observance of 5th November Act)()/gi, protect_function)
		.replace(/(\[\[)(13 May incident)(\|)/gi, protect_function)
		.replace(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function)
		.replace(/(\\'])/gi, protect_function)
		.replace(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function)

		.replace(/(\\])/gi, protect_function)
		.replace(/(.)(4th\sof July)(.)/gi, protect_function)
		.replace(/(\\])/gi, protect_function)
		.replace(/(\\])/gi, protect_function)
		.replace(/(\\])/gi, protect_function)

		// works names
		//.replace(/(.)(protect string)(.)/gi, protect_function)
		.replace(/(.)(11\/22\/63)(.)/gi, protect_function)
		.replace(/(.)(1\.1\.1994)(.)/gi, protect_function)
		.replace(/()(2\.13\.61)()/gi, protect_function)
		//.replace(/(.)(4th of July, Asbury)(.)/gi, protect_function) //protected above globally
		.replace(/(.)(26 October 1993)(.)/gi, protect_function)
		.replace(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function)
		.replace(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function)
		.replace(/(\[\[|\'\')(August 1914)(.)/gi, protect_function)
		.ohc_regex(/(\)/gi, protect_function)
		.ohc_regex(/(\)/gi, protect_function)
		//.replace(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function)
		.replace(/(August)( 7, 4:15)(.)/gi, protect_function)
		.replace(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function)
		.replace(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function)
		.ohc_regex(/(Live at *,? \d)( @fullmonth)(.)/gi, protect_function)
		.ohc_regex(/(Live at *,? @fullmonth)( @dd)(.)/gi, protect_function)
		.ohc_regex(/(Bootmoon Series: * @fullmonth)( @day, @YYYY)(.)/gi, protect_function)

		// expressions and grammatical strings including modal "may"
		//.replace(/(trappist-)(\d{1,3})( may )/g, protect_function) //prospective regex if the line below gives false positives
		.replace(/(\W)((?:\d{1,3}) may )(\w\w+)/g, protect_function)
		.replace(/(\W)((?:\d{3}|3|\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function)
		.replace(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}

/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR ALL REF SECTION

var linkmap = ;

function ohc_protect_dates_ref(editor) {
	// 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;
	};

	editor
		.replace(/(<ref\s?(?:>|name=+))(+)(<\/ref>)/gi, protect_function)
		.replace(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function)
		.replace(/(<math>)(*?)(<\/math>)/gi, protect_function)
		.replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function)
		.replace(/((?:Category|Image|File):)(]*)(])/gi, protect_function)
		.replace(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function)
		.replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{(?:harvnb|wikisource)\|)(+)(\})/gi, protect_function)
		.replace(/(\]*)(\])/gi, protect_function)
		.replace(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function)
		.replace(/(\|archive-?url=https?:|ftp:)(*)(\|)/gi, protect_function)  //repurposed unused line to protect archive url links (archive.today)
		.replace(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function)
		.replace(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function)
		.replace(/((?:image\d?|image_skyline|imagelocation\d?|imagename|imagefile|img|pic)\s*=)(*)()/gi, protect_function)
		.replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function)
		.replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function)
		.replace(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function)
		.replace(/(\{\{navsource\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{singlechart\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{defaultsort:)(+)(\})/gi, protect_function)
		.replace(/(")(*)(")/gi, protect_function)
		.replace(/(“)(*)(”)/gi, protect_function)
		.replace(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function)
		.replace(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function)

		// retraining redirects containing a date
		.replace(/(\\]|\|)/gi, "$1Jiusan Society$2")
		.replace(/(\\]|\|)/gi, "$1Tiananmen Square protests of 1989$2")
		.ohc_regex(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")
		.ohc_regex(/(\\]|\|)/gi, "$1Overthrow of Slobodan Milošević$2")

		// protect alternate meanings of 'may' and 'march' (note: not case insensitive)
		.ohc_regex(/()(@day,?\s{0,3}may)()/g, protect_function)
		.ohc_regex(/()(march\s@day)(\s(?:mile|kilomet|met))/g, protect_function)

		// protect all links containing a date and some text
		.ohc_regex(/(\\|\n]+?@day\|\n]+?@fullmonth\|\n]*)(\]\]|\|)/gi, protect_function)
		.ohc_regex(/(\\|\n]*?@day\|\n]+?@fullmonth(?:,? @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)
		.ohc_regex(/(\\|\n]+?@fullmonth\|\n]+?@day\|\n]*)(\|)/gi, protect_function)
		.ohc_regex(/(\\|\n]*?@fullmonth\|\n]+?@day(?:, @year|) \D\|\n]+\w\s*)(\]\]|\|)/gi, protect_function)

		// protects certain dates
		.replace(/(\)/gi, protect_function)
		.replace(/()(March (?:8|14) Alliance)()/gi, protect_function)
		.replace(/()(23rd March 1931: Shaheed)()/gi, protect_function)
		.replace(/()(Long March )()/gi, protect_function)
		.replace(/()(Bombay March 12)()/gi, protect_function)
		.replace(/()(movement 2 June)()/gi, protect_function)
		.replace(/()(6th\sof October City)()/gi, protect_function)
		.replace(/()(Party Workers' Liberation Front 30th of May)()/gi, protect_function)
		.replace(/()(4th\sof August regime)()/gi, protect_function)
		.replace(/()(19th\sof April movement)()/gi, protect_function)
		.replace(/()(June 4th incident)()/gi, protect_function)
		.replace(/()(The Battle Of Marston Moor \(July 2nd,? 1644\))()/gi, protect_function)
		.replace(/()(Night of January 16th)()/gi, protect_function)
		.replace(/()(Observance of 5th November Act)()/gi, protect_function)
		.replace(/(\[\[)(13 May incident)(\|)/gi, protect_function)
		.replace(/(\'\'\')(22nd\sof May)(\'\'\')/gi, protect_function)
		.replace(/(\\'])/gi, protect_function)
		.replace(/(\[\[)(July 12, 2007, Baghdad airstrike)(\|)/gi, protect_function)

		.replace(/(\\])/gi, protect_function)
		.replace(/(.)(4th\sof July)(.)/gi, protect_function)
		.replace(/(\\])/gi, protect_function)
		.replace(/(\\])/gi, protect_function)
		.replace(/(\\])/gi, protect_function)

		// works names
		//.replace(/(.)(protect string)(.)/gi, protect_function)
		.replace(/(.)(11\/22\/63)(.)/gi, protect_function)
		.replace(/(.)(1\.1\.1994)(.)/gi, protect_function)
		.replace(/()(2\.13\.61)()/gi, protect_function)
		//.replace(/(.)(4th of July, Asbury)(.)/gi, protect_function) //protected above globally
		.replace(/(.)(26 October 1993)(.)/gi, protect_function)
		.replace(/(\[\[|\'\')(June 1, 1974)(.)/gi, protect_function)
		.replace(/(\[\[|\'\')(July 15, 1972)(.)/gi, protect_function)
		.replace(/(\[\[|\'\')(August 1914)(.)/gi, protect_function)
		.ohc_regex(/(\)/gi, protect_function)
		.ohc_regex(/(\)/gi, protect_function)
		//.replace(/(Les Bains Douches 18)( December 1979)(.)/gi, protect_function)
		.replace(/(August)( 7, 4:15)(.)/gi, protect_function)
		.replace(/(In Concert, Zürich, October)( 28, 1979)(.)/gi, protect_function)
		.replace(/(CBGB OMFUG Masters: Live June)( 29, 2001)(.)/gi, protect_function)
		.ohc_regex(/(Live at *,? \d)( @fullmonth)(.)/gi, protect_function)
		.ohc_regex(/(Live at *,? @fullmonth)( @dd)(.)/gi, protect_function)
		.ohc_regex(/(Bootmoon Series: * @fullmonth)( @day, @YYYY)(.)/gi, protect_function)

		.replace(/(\W)((?:\d{3}|3|\d)\/\d dec(?:l\.?|))(\W)/gi, protect_function)
		.replace(/(\W)((?:\d{2,3})\/\d dec(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}


/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR SLASH modules

var linkmap = ;

function ohc_protect_dates_slash(editor) {
	// 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;
	};

	editor
		.replace(/(<ref\s?(?:>|name=+))(+)(<\/ref>)/gi, protect_function)
		.replace(/(<timeline>)(*?)(<\/timeline>)/gi, protect_function)
		.replace(/(<math>)(*?)(<\/math>)/gi, protect_function)
		.replace(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|(})/gi, protect_function)
		.replace(/((?:Category|Image|File):)(]*)(])/gi, protect_function)
		.replace(/(\{(?:See ?also|Main))(\|*)(\})/gi, protect_function)
		.replace(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{(?:harvnb|wikisource)\|)(+)(\})/gi, protect_function)
		.replace(/(\]*)(\])/gi, protect_function)
		.replace(/(>*(?:https?:|ftp:))(]*)(*<)/gi, protect_function)
		//.replace(/(https?:|ftp:)(]*)(])/gi, protect_function)
		.replace(/(<blockquote>)(*?)(<\/blockquote>)/gi, protect_function)
		.replace(/(\{{0,6}(?:quot{1,7}\s?|sic)\|)(+)(\})/gi, protect_function)
		.replace(/((?:image\d?|image_skyline|imagelocation\d?|imagename|imagefile|img|pic)\s*=)(*)()/gi, protect_function)
		.replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function)
		.replace(/(\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)(*)()/gi, protect_function)
		.replace(/(\s*(?:season)\s*=)(\s*\]*\]\]\s*)()/gi, protect_function)
		.replace(/(\{\{navsource\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{singlechart\|)(+)(\})/gi, protect_function)
		.replace(/(\{\{defaultsort:)(+)(\})/gi, protect_function)
		.replace(/(")(*)(")/gi, protect_function)
		.replace(/(“)(*)(”)/gi, protect_function)
		.replace(/(.)(\(\{\{by\|\d{3}\}\}\{\{by\|)(\d{3}*\}\}\))/gi, protect_function)
		.replace(/(.)(\(\{\{by\|\d{3}\}\}(?:present|))(\))/gi, protect_function);
}

function ohc_unprotect_dates(editor) {
	editor
		//unprotect all dates
		.replace(//g, '')
		.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) {
					var res = linkmap;
					res = res.replace(/⍌(+)⍍/g, function (x, n) {
						return linkmap;
					});
					return res;
				});
				return res;
			});
			return res;
		});
}

function ohc_MOSNUM_edit_summary(editor) {
	editor
		.options({ minor: true })
		.appendEditSummary("]-assisted date audit and style fixes per ]")
		.clickDiff();
}

function ohc_bigendien_edit_summary(editor) {
	// add a tag to the summary box
	editor
		.options({ minor: true })
		.appendEditSummary("ymd ref dates")
		.clickDiff();
}

function ohc_expand_edit_summary(editor) {
	// add a tag to the summary box
	editor
		.options({ minor: true })
		.appendEditSummary("expand month names")
		.clickDiff();
}

function ohc_slash_edit_summary(editor) {
	// add a tag to the summary box
	editor
		.options({ minor: true })
		.appendEditSummary("resolved slash dates")
		.clickDiff();
}

function ohc_abbrev_edit_summary(editor) {
	// add a tag to the summary box
	editor
		.options({ minor: true })
		.appendEditSummary("abbrev month names")
		.clickDiff();
}

/** ------------------------------------------------------------------------ **/
/// CUSTOMIZATION POINTS
function ohc_customize_all_to_dmy(editor) { }
function ohc_customize_all_to_mdy(editor) { }
function ohc_customize_body_to_dmy(editor) { }
function ohc_customize_body_to_mdy(editor) { }
function ohc_customize_ISO_to_dmy(editor) { }
function ohc_customize_ISO_to_mdy(editor) { }

/** ------------------------------------------------------------------------ **/
function ohc_body_dates_to_dmy(editor) {
	ohc_use_dates_template(editor, "dmy");

	ohc_fix_common_errors(editor);
	ohc_fix_dts_template(editor, "dmy");
	ohc_fix_gr_template(editor, "dmy");
	ohc_dates_to_dmy(editor);
	ohc_remove_leading_zeroes(editor);
	ohc_fix_dmy_redundancies(editor);
}

function ohc_body_dates_to_mdy(editor) {
	ohc_use_dates_template(editor, "mdy");
	ohc_fix_common_errors(editor);
	ohc_fix_dts_template(editor, "mdy");
	ohc_fix_gr_template(editor, "mdy");
	ohc_dates_to_mdy(editor);
	ohc_remove_leading_zeroes(editor);
	ohc_fix_mdy_redundancies(editor);
}

/** ------------------------------------------------------------------------ **/
function ohc_all_to_dmy_driver(editor) {
	ohc_extend_editor(editor);

	ohc_delink_dates(editor);
	ohc_protect_dates(editor);
	ohc_fix_unambiguous_dates(editor);
	ohc_body_dates_to_dmy(editor);
	ohc_delink_ISO_to_dmy(editor);
	//ohc_delink_year_in_X(editor);
	ohc_customize_all_to_dmy(editor);
	ohc_ISO_to_dmy_in_citations(editor);
	ohc_unprotect_dates(editor);

	ohc_MOSNUM_edit_summary(editor);
}

function ohc_all_to_mdy_driver(editor) {
	ohc_extend_editor(editor);

	ohc_delink_dates(editor);
	ohc_protect_dates(editor);
	ohc_fix_unambiguous_dates(editor);
	ohc_body_dates_to_mdy(editor);
	ohc_delink_ISO_to_mdy(editor);
	//ohc_delink_year_in_X(editor);
	ohc_customize_all_to_mdy();
	ohc_ISO_to_mdy_in_citations(editor);
	ohc_unprotect_dates(editor);

	ohc_MOSNUM_edit_summary(editor);
}

function ohc_dmy_publication_dates_driver(editor) {
	ohc_extend_editor(editor);

	//ohc_delink_dates(editor);
	ohc_protect_dates(editor);
	ohc_body_dates_to_dmy(editor);
	ohc_customize_body_to_dmy(editor);
	ohc_dmy_publication_dates(editor);
	ohc_unprotect_dates(editor);

	ohc_MOSNUM_edit_summary(editor);
}

function ohc_mdy_publication_dates_driver(editor) {
	ohc_extend_editor(editor);

	//ohc_delink_dates(editor);
	ohc_protect_dates(editor);
	ohc_body_dates_to_mdy(editor);
	ohc_customize_body_to_mdy(editor);
	ohc_mdy_publication_dates(editor);
	ohc_unprotect_dates(editor);

	ohc_MOSNUM_edit_summary(editor);

}

function ohc_body_to_dmy_driver(editor) {
	ohc_extend_editor(editor);

	//ohc_delink_dates(editor);
	ohc_protect_dates_ref(editor);
	ohc_body_dates_to_dmy(editor);
	ohc_customize_body_to_dmy(editor);
	ohc_unprotect_dates(editor);

	ohc_MOSNUM_edit_summary(editor);
}

function ohc_body_to_mdy_driver(editor) {
	ohc_extend_editor(editor);

	//ohc_delink_dates(editor);
	ohc_protect_dates_ref(editor);
	ohc_body_dates_to_mdy(editor);
	ohc_customize_body_to_mdy(editor);
	ohc_unprotect_dates(editor);

	ohc_MOSNUM_edit_summary(editor);
}

function ohc_ISO_to_dmy_driver(editor) {
	ohc_extend_editor(editor);

	ohc_protect_dates(editor);
	ohc_delink_ISO_to_dmy(editor);
	ohc_customize_ISO_to_dmy(editor);
	ohc_unprotect_dates(editor);

	//ohc_MOSNUM_edit_summary(editor);
}

function ohc_ISO_to_mdy_driver(editor) {
	ohc_extend_editor(editor);

	ohc_protect_dates(editor);
	ohc_delink_ISO_to_mdy(editor);
	ohc_customize_ISO_to_mdy(editor);
	ohc_unprotect_dates(editor);

	//ohc_MOSNUM_edit_summary(editor);
}

function ohc_delink_year_in_X_driver(editor) {
	ohc_extend_editor(editor);

	ohc_delink_year_in_X(editor);
}

function ohc_expand_ref_dates_driver(editor) {
	ohc_extend_editor(editor);

	ohc_expand_ref_dates(editor);
	ohc_protect_dates(editor);
	ohc_unprotect_dates(editor);
	ohc_expand_edit_summary(editor);
}

function ohc_expand_all_dates_driver(editor) {
	ohc_extend_editor(editor);

	ohc_expand_ref_dates(editor);
	ohc_protect_dates(editor);
	ohc_expand_all_dates(editor);
	ohc_unprotect_dates(editor);
	ohc_expand_edit_summary(editor);
}

function ohc_abbrev_ref_dates_driver(editor) {
	ohc_extend_editor(editor);

	ohc_protect_dates(editor);
	ohc_abbrev_ref_dates(editor);
	ohc_unprotect_dates(editor);
	ohc_slash_edit_summary(editor);
}

function ohc_UK_slash_dates_driver(editor) {
	ohc_extend_editor(editor);

	ohc_expand_ref_dates(editor);
	ohc_protect_dates_slash(editor);
	ohc_UK_slash_dates_to_dmy(editor);
	ohc_unprotect_dates(editor);
	ohc_slash_edit_summary(editor);
}

function ohc_US_slash_dates_driver(editor) {
	ohc_extend_editor(editor);

	ohc_expand_ref_dates(editor);
	ohc_protect_dates_slash(editor);
		ohc_US_slash_dates_to_mdy(editor);
	ohc_unprotect_dates(editor);
	ohc_expand_edit_summary(editor);
}

// </pre>