User:Ohconfucius/script/dateabbreviations.js

/************* mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js&action=raw&ctype=text/javascript'); function Ohc_expand { var	txt=document.editform.wpTextbox1; regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )Jan\.?(?: | )([12]\d{3})/gi, '$1$2 January $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d)(?: | )Febr?\.?(?: | )([12]\d{3})/gi, '$1$2 February $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )Mar\.?(?: | )([12]\d{3})/gi, '$1$2 March $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )Apr\.?(?: | )([12]\d{3})/gi, '$1$2 April $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )Jun\.?(?: | )([12]\d{3})/gi, '$1$2 June $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )Jul\.?(?: | )([12]\d{3})/gi, '$1$2 July $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )Aug\.?(?: | )([12]\d{3})/gi, '$1$2 August $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )Sept?\.?(?: | )([12]\d{3})/gi, '$1$2 September $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )Oct\.?(?: | )([12]\d{3})/gi, '$1$2 October $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )Nov\.?(?: | )([12]\d{3})/gi, '$1$2 November $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )Dec\.?(?: | )([12]\d{3})/gi, '$1$2 December $3');
 * regex menu framework
 * by m:user:Pathoschild 
 * - adds a sidebar menu of user-defined scripts.

regex(/\(([0-2]?\d|30|31)(?: | )Jan\.?(?: | )([12]\d{3})\)/gi, '($1 January $2)'); regex(/\(([0-2]?\d)(?: | )Febr?\.?(?: | )([12]\d{3})\)/gi, '($1 February $2)'); regex(/\(([0-2]?\d|30|31)(?: | )Mar\.?(?: | )([12]\d{3})\)/gi, '($1 March $2)'); regex(/\(([0-2]?\d|30)(?: | )Apr\.?(?: | )([12]\d{3})\)/gi, '($1 April $2)'); regex(/\(([0-2]?\d|30)(?: | )Jun\.?(?: | )([12]\d{3})\)/gi, '($1 June $2)'); regex(/\(([0-2]?\d|30|31)(?: | )Jul\.?(?: | )([12]\d{3})\)/gi, '($1 July $2)'); regex(/\(([0-2]?\d|30|31)(?: | )Aug\.?(?: | )([12]\d{3})\)/gi, '($1 August $2)'); regex(/\(([0-2]?\d|30)(?: | )Sept?\.?(?: | )([12]\d{3})\)/gi, '($1 September $2)'); regex(/\(([0-2]?\d|30|31)(?: | )Oct\.?(?: | )([12]\d{3})\)/gi, '($1 October $2)'); regex(/\(([0-2]?\d|30)(?: | )Nov\.?(?: | )([12]\d{3})\)/gi, '($1 November $2)'); regex(/\(([0-2]?\d|30|31)(?: | )Dec\.?(?: | )([12]\d{3})\)/gi, '($1 December $2)');

regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Jan\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1January $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Febr?\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1February $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Mar\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1March $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Apr\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1April $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Jun\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1June $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Jul\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1July $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Aug\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1August $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Sept?\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1September $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Oct\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1October $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Nov\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1November $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))Dec\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1December $2, $3');

regex(/\(Jan\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(January $1, $2)'); regex(/\(Febr?\.?(?: | )([0-2]?\d),?(?: | )([12]\d{3})\)/gi, '(February $1, $2)'); regex(/\(Mar\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(March $1, $2)'); regex(/\(Apr\.?(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(April $1, $2)'); regex(/\(Jun\.?(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(June $1, $2)'); regex(/\(Jul\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(July $1, $2)'); regex(/\(Aug\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(August $1, $2)'); regex(/\(Sept?\.?(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(September $1, $2)'); regex(/\(Oct\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(October $1, $2)'); regex(/\(Nov\.?(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(November $1, $2)'); regex(/\(Dec\.?(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(December $1, $2)'); }

function Ohc_run_expand { var txt=document.editform.wpTextbox1; Ohc_expand;

// Add a tag to the summary box var txt=document.editform.wpSummary; var summary = "expand month names"; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; }		txt.value += summary; }  document.forms.editform.wpMinoredit.checked = true; document.editform.wpDiff.click;

} function Ohc_abbreviate { var	txt=document.editform.wpTextbox1; regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )January,?(?: | )([12]\d{3})/gi, '$1$2 Jan. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d)(?: | )February,?(?: | )([12]\d{3})/gi, '$1$2 Feb. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )March,?(?: | )([12]\d{3})/gi, '$1$2 Mar. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )April,?(?: | )([12]\d{3})/gi, '$1$2 Apr. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )June,?(?: | )([12]\d{3})/gi, '$1$2 Jun. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )July,?(?: | )([12]\d{3})/gi, '$1$2 Jul. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )August,?(?: | )([12]\d{3})/gi, '$1$2 Aug. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )September,?(?: | )([12]\d{3})/gi, '$1$2 Sep. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )October,?(?: | )([12]\d{3})/gi, '$1$2 Oct. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30)(?: | )November,?(?: | )([12]\d{3})/gi, '$1$2 Nov. $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))([0-2]?\d|30|31)(?: | )December,?(?: | )([12]\d{3})/gi, '$1$2 Dec. $3');

regex(/\(([0-2]?\d|30|31)(?: | )January,?(?: | )([12]\d{3})\)/gi, '($1 Jan.$2)'); regex(/\(([0-2]?\d)(?: | )February,?(?: | )([12]\d{3})\)/gi, '($1 Feb.$2)'); regex(/\(([0-2]?\d|30|31)(?: | )March,?(?: | )([12]\d{3})\)/gi, '($1 Mar.$2)'); regex(/\(([0-2]?\d|30)(?: | )April,?(?: | )([12]\d{3})\)/gi, '($1 Apr.$2)'); regex(/\(([0-2]?\d|30)(?: | )June,?(?: | )([12]\d{3})\)/gi, '($1 Jun.$2)'); regex(/\(([0-2]?\d|30|31)(?: | )July,?(?: | )([12]\d{3})\)/gi, '($1 Jul.$2)'); regex(/\(([0-2]?\d|30|31)(?: | )August,?(?: | )([12]\d{3})\)/gi, '($1 Aug.$2)'); regex(/\(([0-2]?\d|30)(?: | )September,?(?: | )([12]\d{3})\)/gi, '($1 Sep.$2)'); regex(/\(([0-2]?\d|30|31)(?: | )October,?(?: | )([12]\d{3})\)/gi, '($1 Oct.$2)'); regex(/\(([0-2]?\d|30)(?: | )November,?(?: | )([12]\d{3})\)/gi, '($1 Nov.$2)'); regex(/\(([0-2]?\d|30|31)(?: | )December,?(?: | )([12]\d{3})\)/gi, '($1 Dec.$2)');

regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))January(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Jan. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))February(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Feb. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))March(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Mar. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))April(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Apr. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))June(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Jun. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))July(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Jul. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))August(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Aug. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))September(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Sep. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))October(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Oct. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))November(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Nov. $2, $3'); regex(/(\|[ ]*(?:date|archivedate|accessdate)[ ]*=[ ]*|(?:Accessed|Retrieved) (?:on |))December(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})/gi, '$1Dec. $2, $3');

regex(/\(January(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(Jan. $1, $2)');	regex(/\(February(?: | )([0-2]?\d),?(?: | )([12]\d{3})\)/gi, '(Feb. $1, $2)');	regex(/\(March(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(Mar. $1, $2)');	regex(/\(April(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(Apr. $1, $2)');	regex(/\(June(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(Jun. $1, $2)');	regex(/\(July(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(Jul. $1, $2)');	regex(/\(August(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(Aug. $1, $2)');	regex(/\(September(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(Sep. $1, $2)');	regex(/\(October(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(Oct. $1, $2)');	regex(/\(November(?: | )([0-2]?\d|30),?(?: | )([12]\d{3})\)/gi, '(Nov. $1, $2)');	regex(/\(December(?: | )([0-2]?\d|30|31),?(?: | )([12]\d{3})\)/gi, '(Dec. $1, $2)'); }

function Ohc_run_abbreviate { var txt=document.editform.wpTextbox1; Ohc_abbreviate;

// Add a tag to the summary box var txt=document.editform.wpSummary; var summary = "abbreviate month names"; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; }		txt.value += summary; }  document.forms.editform.wpMinoredit.checked = true; document.editform.wpDiff.click;

}

$.when(mw.loader.using('mediawiki.util'), $.ready).done(function { 	if(document.forms.editform) {  mw.util.addPortletLink('p-tb', 'javascript:Ohc_run_expand', 'EXPAND month', 't-addmetric', 'Month names in full', , );  mw.util.addPortletLink('p-tb', 'javascript:Ohc_run_abbreviate', 'ABBREV month', 't-addmetric', 'Month names abbreviated', , );  } });