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

Content deleted Content added
November
tweaks
Line 4:
// PLEASE READ THE DOCUMENTATION at [[User:Ohconfucius/MOSNUM dates]] (click on the link above) before using.
 
// Feedback and constructive criticism are welcome... however, please don't tell me something I know already
 
function Ohc_fix_common_errors() {
var txt=document.editform.wpTextbox1;
 
protect_dates_in_titles();
// capitalise month names
txt.value=txt.value.replace(/(\s)jan(|uary|\.)(\s)/g, '$1Jan$2$3');
txt.value=txt.value.replace(/(\s)feb(|ruary|\.)(\s)/g, '$1Feb$2$3');
txt.value=txt.value.replace(/(\d\s)mar(|ch|\.)(\s)/g, '$1Mar$2$3');
txt.value=txt.value.replace(/(\s)mar(|ch|\.)(\s\d)/g, '$1Mar$2$3');
txt.value=txt.value.replace(/(\s)apr(|il|\.)(\s)/g, '$1Apr$2$3');
txt.value=txt.value.replace(/(\d\s)may(,|\.)(\s)/g, '$1May$2$3');
txt.value=txt.value.replace(/(\s)may(|\.)(\s\d)/g, '$1May$2$3');
txt.value=txt.value.replace(/(\s)jun(|e|\.)(\s)/g, '$1Jun$2$3');
txt.value=txt.value.replace(/(\s)jul(|y|\.)(\s)/g, '$1Jul$2$3');
txt.value=txt.value.replace(/(\s)aug(|ust|\.)(\s)/g, '$1Aug$2$3');
txt.value=txt.value.replace(/(\s)sep(|tember|\.)(\s)/g, '$1Sep$2$3');
txt.value=txt.value.replace(/(\d{1,2}\s)sept(\s)/g, '$1Sep$2');
txt.value=txt.value.replace(/(\s)oct(|ober|\.)(\s)/g, '$1Oct$2$3');
txt.value=txt.value.replace(/(\s)nov(|ember|\.)(\s)/g, '$1Nov$2$3');
txt.value=txt.value.replace(/(\s)dec(|ember|\.)(\s)/g, '$1Dec$2$3');
 
//underscore in linked dates - dmy
txt.value=txt.value.replace(/(\[\[[0-3]?\d)_(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\]\])/gi, '$1 $2$3');
Line 37 ⟶ 21:
//rem redundant spaces (and commas) in date formats
txt.value=txt.value.replace(/([^\d][^\w\d]\[?\[?[0-3]?\d)[ ]+(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\]\])?[ ]*,[ ]*(\[?\[?\d{3,4}(\sAD|\sBC|\sCE|\sBCE|)\]?\]?[^\w\d][^\d])/gi, '$1 $2$3 $4');
txt.value=txt.value.replace(/([^\d][^\w\d]\[?\[?)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))[ ]+([0-32]?\d|30|31)(\]?\]?)(?:[ ]*,[ ]*)(\[?\[?[1-9]\d{32,43}(\sAD|\sBC|\sCE|\sBCE|)\]?\]?[^\w\d][^\d])/gi, '$1$2 $3$4, $5');
txt.value=txt.value.replace(/([^\d][^\w\d]\[?\[?)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))[ ]+([0-32]?\d|30|31)(\]?\]?)[ ]+(\[?\[?\d{3,4}(\sAD|\sBC|\sCE|\sBCE|)\]?\]?[^\w\d][^\d])/gi, '$1$2 $3$4, $5');
 
txt.value=txt.value.replace(/(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(?:, | of )(\d{3,4}[\w\d])/gi, '$1 $2'); //repeat after delinking
 
Ohc_protect_dates_in_titles();
//remove unlinked ordinal date formats
txt.value=txt.value.replace(/(?:the\s?)?([1-3]?\d)(?:th|st|nd|rd|), ([1-3]?\d)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s[1-3]?\d)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d])/gi, '$1, $2$3 $4 $5');
txt.value=txt.value.replace(/(?:the\s?)?([1-3]?\d)(?:th|st|nd|rd|)(\s(?:and|&|to|or)\s[1-3]?\d)(?:th|st|nd|rd|)(?:\sof\s?)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d])/gi, '$1$2 $3$4');
Line 65 ⟶ 49:
 
//permanent protection for dmy dates within images
txt.value=txt.value.replace(/((?:file|image|img)[\s]*[:=][^\|]{1,30})\s([0-32]?\d|30|31)(th|st|nd|rd|)(\sof)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(,)?(\s(?:\d{3,4}))?/gi, '$1_$2$3$4_$5$66_$7');
txt.value=txt.value.replace(/(\((?:file|image|img)[^\ds]*[^\w\d:=])([0-3]?\d)(?:th|st|nd|rd|)[(\sof)?\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^,)?\ws(\d][^\d]|[ ]*\r{3,4})/gi, '$1$3 $2$3_$4$5_$6_$7');
txt.value=txt.value.replace(/((?:file|image|img)[^\ds]*[:=][^\w\d|]{1,30})\s([0-32]?\d|30|31)(?:th|st|nd|rd|)[(\sof)?\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(,)?(\s(?:\d{3,4})([^\w\d][^\d]|[ ]*\r)?/gi, '$11_$2$3 $2, $44_$5$6$7');
txt.value=txt.value.replace(/(\((?:file|image|img)[\s]*[:=][0-3]?\d)(th|st|nd|rd|)(\sof)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(,)?(\s(?:\d{3,4}))?/gi, '$1$2$3_$4$5_$6$7');
 
txt.value=txt.value.replace(/([0-32]?\d|30|31)(th|st|nd|rd|)(\sof)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(,)?\s(\d{3,4})(\.jpe?g)/gi, '$1$2$3_$4$5_$6$7');
txt.value=txt.value.replace(/([0-32]?\d|30|31)(th|st|nd|rd|)(\sof)?\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\.jpe?g)/gi, '$1$2$3_$4$5');
 
//protect dmy date formats within titles of citation templates
txt.value=txt.value.replace(/(\|[ ]*(?:title|work|quote)[ ]*=[^\|]*)((?:[0-3]?\d)(?:th|st|nd|rd|),?(?:\sof)?)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\|]{0,30}*?\|)/gi, '$1$2 $3$4');
//blockquotes
txt.value=txt.value.replace(/(<blockquote>[^<]+?)((?:[0-3]?\d)(?:th|st|nd|rd|),?(?:\sof)?)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(,)?\s?(\d{1,4})?([^<]+?<\/blockquote>)/g, '$1$2&nbsp;$3$4');
Line 78 ⟶ 64:
//permanent protection for mdy dates within images
txt.value=txt.value.replace(/((?:file|image|img)[\s]*[:=][^\|]{1,60})\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-32]?\d|30|31)(th|st|nd|rd|)(,)?(\s(?:\d{3,4}))?/gi, '$1_$2$3_$4$5$66_$7');
txt.value=txt.value.replace(/((?:file|image|img)[\s]*[:=])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-32]?\d|30|31)(th|st|nd|rd|)(,)?(\s(?:\d{3,4}))?/gi, '$1$2$3_$4$5$66_$7'); //re-enabled 13 Aug 2010
 
txt.value=txt.value.replace(/(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-3]?\d)(th|st|nd|rd|)(,)?\s(\d{3,4})(\.(?:png|jpe?g))/gi, '$1$2_$3$4$5_$6$7');
txt.value=txt.value.replace(/((?:file|image|img)[\s]*[:=][^\|]{1,60})\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-32]?\d|30|31)(th|st|nd|rd|)(,)?(\.png|\.jpes(?g:\d{3,4}))?/gi, '$11_$2_2$33_$4$5$6$7');
txt.value=txt.value.replace(/((?:file|image|img)[\s]*[:=])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-2]?\d|30|31)(th|st|nd|rd|)(,)?(\s(?:\d{3,4}))?/gi, '$1$2$3_$4$5$6$7');
//re-enabled 13 Aug 2010
txt.value=txt.value.replace(/(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-32]?\d|30|31)(th|st|nd|rd|)(,)?\s(\d{3,4})(\.(?:png|jpe?g))/gi, '$1$2_$3$4$5_$6$7');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s([0-32]?\d|30|31)(?:th|st|nd|rd|),?\s(\d{1,4})([^\w\d][^\d].png|[ ]*\r.jpe?g)/gi, '$1$2_$3 $2 $4$5');
 
//protect mdy date formats within titles of citation templates
txt.value=txt.value.replace(/(\|[ ]*(?:title|work|quote|chapter)[ ]*=[^\|]+?)([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s((?:[0-3]?\d)(?:th|st|nd|rd|))([^\w|\d]*?\|)/gi, '$1$2$3$4&nbsp;$5$6');
//blockquotes
txt.value=txt.value.replace(/(<blockquote>[^<]+?)([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\sthe)?\s((?:[0-3]?\d)(?:th|st|nd|rd|),?)\s(\d{1,4})([^<]+?<\/blockquote>)/g, '$1$2$3$4&nbsp;$5&nbsp;$6$7');
 
}
 
Line 102 ⟶ 91:
txt.value=txt.value.replace(/\[\[(\d{4})\]\]-([0-1]\d-[0-3]\d)/gi, '$1-$2');
 
//delink full dates - dmy
txt.value=txt.value.replace(/(\[^\d][^\w\d])([01-3]?\d)(?:th|st|nd|rd|)[\ss_]{1,3}(?:of[\s_])?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),(?:\s]\] \[\[| )(\d{1,4}\s?(?:AD|BC|CE|BCE)[^\w\d][^\d])/gi, '$1$3 $2, $43');
 
txt.value=txt.value.replace(/(\[^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)) (?:the\s)?([01-3]?\d)(?:th|st|nd|rd|)((?:\]\],? \s[0-3]?\d(?:th[|st|nd|rd|)){0,6} ), ([0-3]?\d{4})(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1 $3$42, $5 $2$63');
 
//delink single dm or 'dth the m'
txt.value=txt.value.replace(/(?:the\s)?\[\[([1-3]?\d)(?:th|st|nd|rd|)[\s_](?:of[\s_])?(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\]\]/gi, '$1 $2');
 
Line 112 ⟶ 106:
 
//removal of 'year in foo' in full dates (with or without links) with incorrect '[[year in foo|YYYY]]'
// txt.value=txt.value.replace(/(\[?\[?(?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:[0-3][\d]|[\d])\]?\]?),\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]/gi, '$1 $2');
// txt.value=txt.value.replace(/(\[?\[?(?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(?:[0-3][\d]|[\d])\]?\]?),\s{{(?:avyear|by|fy|ly|mlb|scy|sdy)\|(\d{1,4})}}/gi, '$1 $2');
// txt.value=txt.value.replace(/(\[?\[?(?:[0-3][\d]|[\d])\s(?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\]?\]?)\s\[\[(\d{1,4})\sin\s[^\]]{1,32}\]\]/gi, '$1 $2');
// txt.value=txt.value.replace(/(\[?\[?(?:[0-3][\d]|[\d])\s(?:Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.?|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\]?\]?)\s{{(?:avyear|by|fy|ly|mlb|scy|sdy)\|(\d{1,4})}}/gi, '$1 $2');
 
//month+day+year piped pseudo-ISO dates
Line 179 ⟶ 173:
 
// spaces and commas - mdy birth and death date ranges
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31),? (\d{1,3}|[12]?\d{3})(?:[ ]*[-–][ ]*)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31),? (\d{1,3}|[12]?\d{3})([^\d][^\w\d])/gi, '$1$2 $3, $4 – $5 $6, $7$8');
//dmy birth and death date ranges)
txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),? (\d{1,3}|[12]?\d{3})(?:\s?[-–]\s?)([0-32]?\d|30|31)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),? (\d{1,3}|[12]?\d{3})([^\d][^\w\d])/gi, '$1$2 $3 $4 – $5 $6 $7$8');
 
}
Line 191 ⟶ 185:
txt.value=txt.value.replace(/([^\d\w\/\-%,])(\d{4}-\d\d-\d\d)(<\s?\/ref.*?>)/g, '$1$2 $3');
 
//code to convert ref ISO-dates outside citation templates and between ref tags
txt.value=txt.value.replace(/(<\s?ref.*?>[^<]+?)([\s\(])(\d{4})-01-0(\d)([^\d\w\/\-%,])([^<]*?<\s?\/ref.*?>)/g, '$1$2$4 January $3$5$6');
txt.value=txt.value.replace(/(<\s?ref.*?>[^<]+?)([\s\(])(\d{4})-02-0(\d)([^\d\w\/\-%,])([^<]*?<\s?\/ref.*?>)/g, '$1$2$4 February $3$5$6');
Line 262 ⟶ 256:
var txt=document.editform.wpTextbox1;
 
txt.value=txt.value.replace(/{{(?:avyear|npby|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(\d{1,4})}}/gi, '$1');
txt.value=txt.value.replace(/{{(?:avyear|npby|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(?:\d{1,4})\|(\d{1,4})}}/gi, '$1');
txt.value=txt.value.replace(/\[\[\d{1,4}\sin\s[^\|]+\|(\d{1,4})\]\]/gi, '$1');
txt.value=txt.value.replace(/\[\[(?:\d{4}.\d{2} in English football)\|([^\]]{1,30})\]\]/gi, '$1');
 
txt.value=txt.value.replace(/\[\[\d{4,4} Major League Baseball season\|(\d{4,4})(\sseason)?\]\]/gi, '$1$2');
 
 
}
Line 281 ⟶ 274:
//protect certain dates
txt.value=txt.value.replace(/(\[\[4)(AD)/gi, '$1♫$2');
txt.value=txt.value.replace(/(\s)feb[\[(?:2300|ruary|2000))\.)s(AD\s]\])/ggi, '$1Feb1♫$2$3');
txt.value=txt.value.replace(/(March )((?:8|14) Alliance)/gi, '$1♫$2');
txt.value=txt.value.replace(/(6th\sof\s)(October City)/gi, '$1♫$2');
txt.value=txt.value.replace(/(\[\[May\s1968)(\]\])/gi, '$1 in France|May 1968$2');
txt.value=txt.value.replace(/(\[\[June )(1, 1974\]\])/gi, '$1♫$2'); //June 1, 1974 is the name of an album
txt.value=txt.value.replace(/(\'\'June )(1, 1974\'\')/gi, '$1♫$2');
txt.value=txt.value.replace(/(26th\[sof\[(?:2300|2000s))\s(AD\]\]July Movement)/gi, '$1♫$2');
txt.value=txt.value.replace(/(6th\dsof\s)mar(|ch|\.)(\sOctober City)/ggi, '$1Mar1♫$2$3');
}
Line 294 ⟶ 288:
//unprotect certain dates
txt.value=txt.value.replace(/(\[\[4)♫(AD)/gi, '$1♫$2');
txt.value=txt.value.replace(/(\[\[(?:82300|142000))♫(March AllianceAD]\])/gi, '$1 $2');
txt.value=txt.value.replace(/(\s[\[March )apr((?:8|il|\.14)(\s Alliance)/ggi, '$1Apr1$2$3');
txt.value=txt.value.replace(/(\sJune )jan(|uary|\.)(\s1, 1974)/ggi, '$1Jan1$2$3');
txt.value=txt.value.replace(/(26th\sof\s)mar(|ch|\.)(\s\dJuly Movement)/ggi, '$1Mar1$2$3');
txt.value=txt.value.replace(/(6th\sof\s)♫(October City)/gi, '$1$2');
 
txt.value=txt.value.replace(/(June )♫(1, 1974)/gi, '$1$2');
txt.value=txt.value.replace(/(\[\[(?:2300|2000)w)♫(AD]\]w)/gig, '$1 $2'); //remove any spurious protection markers
txt.value=txt.value.replace(/(\w)♫(\w)/g, '$1$2'); //2010-10-06 quick patch to remove any spurious protection markers
txt.value=txt.value.replace(/\x02([0-9]+)\x03/g, function(x, n){
return linkmap[n];
Line 319 ⟶ 315:
var txt=document.editform.wpTextbox1;
// insert 'dmy' template
txt.value=txt.value.replace(/{{(use (dmy|mdy) dates|mdydmy)(\|[^}]*)?}}/gi, '{{Use dmy dates|date=November 2010}}');
if (txt.value.search(/{{use dmy dates|date=November 2010}}/gi) == -1)
{
txt.value='{{Use dmy dates|date=November 2010}}\r\n'+txt.value;
Line 338 ⟶ 334:
 
//convert mdy-mdy to dmy-dmy (birth and death date ranges)
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31), ([12]?\d{0,3})(?:\s?[-–]\s?)(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31), ([12]?\d{0,3})([^\d][^\w\d])/gi, '$1$3 $2 $4 – $6 $5 $7$8');
 
//convert md-mdy date ranges to dm-dmy
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|)((?:,?\/|\s?[0-3]\s?|\ds(?:thand|stto|nd&)\s)(Jan(?:uary|rd\.|)|Feb(?:ruary|\.|){0,6}|Mar(?:ch|\.|),|Apr(?:il|\.|)|May|Jun(?:e|\/.|)|Jul(?:y|\s.|)|Aug(?[-–]:ust|\s.|)|Sep(?:tember|\s.|t\.|)|Oct(?:andober|to\.|&)|Nov(?:ember|\s.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|),?\s(?:of\s)?(\d{3,4}[^\w\d][^\d])/gi, '$1$3 $4$52 – $6 $2 5$7');
//test code txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|)((?:,?\/|\s?[0-3]\s?|\ds(?:thand|stto|nd&)\s)(Jan(?:uary|rd\.|)|Feb(?:ruary|\.|){0,6}|Mar(?:ch|\.|),|Apr(? :il|\.|)|May|Jun([0-3]?:e|\d.|)|Jul(?:thy|st\.|nd)|rdAug(?:ust|\.|),|Sep(?:tember|\s.|t\.|)|Oct(?:ofober|\s.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-2]?\d{3,4}|30|31)(?:th|st|nd|rd|)([^\w\d][^\d])/gi, '$1$3 $4,2 – $56 $25$67');
//convert md-dy date ranges to d-dmy
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-3]?\d)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}), ([0-3]?\d)(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1$3$4, $5 $2$6');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),?(\/|\s?[-–]\s?|\s(?:and|to|&)\s)([0-2]?\d|30|31)(?:th|st|nd|rd|),?\s(?:of\s)?(\d{3,4}[^\w\d][^\d])/gi, '$1$3$4$5$6 $2 $7');
//test code txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),? ([0-2]?\d|30|31)(?:th|st|nd|rd|),?\s(?:of\s)?(\d{3,4}[^\w\d][^\d])/gi, '$1$3$4, $5 $2$6');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-2]?\d|30|31)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}), ([0-2]?\d|30|31)(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1$3$4, $5 $2$6');
 
//convert md,d,d, date ranges to d,d,dm (multiple, separated by commas)
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?:th|st|nd|rd|)((?:,?\s[0-3]?\d(?:th|st|nd|rd|)){0,6}),?(\/|\s?[-–]\s?|\s(?:and|to|&)\s)([0-32]?\d|30|31)(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1$3$4$5$6 $2$7');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))((?:\s[1-3]?\d(?:th|st|nd|rd|),?){1,6})(\s(?:and|to|&)\s)([0-32]?\d|30|31)(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1$3$4$5 $2$6');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?:th|st|nd|rd|)((?:,?\s[1-3]?\d(?:th|st|nd|rd|)){1,6})([^\w\d][^\d]|[ ]*\r)/gi, '$1$3$4 $2$5');
//convert md date ranges to dm (simple, separated by hyphens and dashes or 'to')
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([1-3]?\d)(?:th|st|nd|rd|)(\s?[-–]\s?|\sto\s)([0-32]?\d|30|31)(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $4$5 $2$6');
 
//'md, md,' to 'dm, dm,'
txt.value=txt.value.replace(/([^\d])( (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)))( [0-32]?\d| 30| 31),( (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)))( [0-32]?\d| 30| 31)([,\.][^\w\d][^\d])/gi, '$1$3$2,$5$4,$6');
 
//convert simple mdy dates to dmy
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|),?\s(\d{1,4}\s?(?:AD|BC|CE|BCE)[^\w\d][^\d])/gi, '$1$3 $2 $4');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|),?\s(\d{3,4})([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2 $4$5');
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|)([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2$4');
//Repeat line to capture some instances that get missed first time
//(needed because the date component 'September 19, 1881' within the string 'March 4-September 19, 1881' is blocked from conversion by the '4')
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-3]?\d)(?:th|st|nd|rd|),?\s(\d{1,4})([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2 $4$5');
 
//Month+day_number " 7th March" -> "7 March"
txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d{1,4})([^\w\d][^\d]|[ ]*\r)/gi, '$1$2 $3 $4$5');
txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d]|[ ]*\r)/gi, '$1$2 $3$4');
 
Ohc_remove_leading_zeros_from_nonlinked_dates ();
Line 379 ⟶ 375:
// insert 'mdy' template
txt.value=txt.value.replace(/{{(use (dmy|mdy) dates|dmy)(\|[^}]*)?}}/gi, '{{Use mdy dates|date=November 2010}}');
if (txt.value.search(/{{use mdy dates|date=November 2010}}/gi) == -1)
{
txt.value='{{Use mdy dates|date=November 2010}}\r\n'+txt.value;
Line 394 ⟶ 390:
 
//convert dmy-dmy to mdy-mdy (birth and death date ranges)
txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),? ([12]?\d{0,3})(?:\s?[-–]\s?)([0-32]?\d|30|31)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),? ([12]?\d{0,3})([^\d][^\w\d])/gi, '$1$3 $2, $4 – $6 $5, $7$8');
 
//convert dm-dmy date ranges to md-mdy
txt.value=txt.value.replace(/([^\d][^\w\d])((?:[0-32]?\d|30|31)(?:th|st|nd|rd|),\s(Jan(?:uary|\.|){0,6}|Feb([0-3]?:ruary|\d.|)|Mar(?:thch|st\.|nd)|rdApr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\/|[\s]{0,3}(?:and|to|&|-|–)[\s]{0,3})([0-32]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d{3,4}[^\w\d][^\d])/gi, '$1$63 $2$3$46 $5, $7');
txt.value=txt.value.replace(/([^\d][^\w\d])([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))(\/|[\s]{0,3}(?:and|to|&|-|–)[\s]{0,3})([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d])/gi, '$1$3 $2 – $6 $5,$7');
//convert d-dmy date ranges to md-d,y
txt.value=txt.value.replace(/([^\d][^\w\d])((?:[0-2]?\d|30|31)(?:th|st|nd|rd|),\s){0,6}([0-2]?\d|30|31)(?:th|st|nd|rd|)(\/|[\s]{0,3}(?:and|to|&|-|–)[\s]{0,3})([0-2]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s(\d{3,4}[^\w\d][^\d])/gi, '$1$6 $2$3$4$5, $7');
 
//convert d,d,dm date ranges to md,d,d (multiple, separated by commas)
txt.value=txt.value.replace(/([^\d][^\w\d])((?:[0-3]?\d(?:th|st|nd|rd|),?\s){0,6})([0-32]?\d|30|31)(?:th|st|nd|rd|)(\/|[\s]{0,3}(?:and|to|&|-|–)[\s]{0,3})([0-32]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d]|[ ]*\r)/gi, '$1$6 $2$3$4$5$7');
txt.value=txt.value.replace(/([^\d][^\w\d])((?:[0-3]?\d(?:th|st|nd|rd|),?[\s]{1,3}){1,6})([0-32]?\d|30|31)(?:th|st|nd|rd|)\s(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d]|[ ]*\r)/gi, '$1$4 $2$3$5');
//convert dm date ranges to md (simple, separated by hyphen, dash or 'to')
txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)(?:th|st|nd|rd|)([\s]{0,3}[-–][\s]{0,3}|\sto[\s]{0,3})([0-32]?\d|30|31)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d]|[ ]*\r)/gi, '$1$5 $2$3$4$6');
 
//'dm, dm,' to 'md, md,'
txt.value=txt.value.replace(/([^\d])( [0-32]?\d| 30| 31)( (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))),( [0-32]?\d| 30| 31)( (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)))([,\.]?[^\w\d][^\d])/gi, '$1$3$2,$5$4,$6');
 
txt.value=txt.value.replace(/([^\d][^\w\d])([0-3]?\d)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(\d{1,4}\s?(?:AD|BC|CE|BCE)[^\w\d][^\d])/gi, '$1$3 $2, $4');
txt.value=txt.value.replace(/([^\d][^\w\d])([0-3]?\d)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(\d{3,4})([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2, $4$5');
txt.value=txt.value.replace(/([^\d][^\w\d])([0-3]?\d)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2$4');
 
txt.value=txt.value.replace(/([^\d][^\w\d])([0-2]?\d|30|31)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(\d{1,4}\s?(?:AD|BC|CE|BCE)[^\w\d][^\d])/gi, '$1$3 $2, $4');
//repeat previous two bits of code to capture some date ranges that were missed first time round
// txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|)),?\s(\d{13,4})([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2, $4$5');
// txt.value=txt.value.replace(/([^\d][^\w\d])([0-32]?\d|30|31)(?:th|st|nd|rd|)[\s]{1,3}(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))([^\w\d][^\d]|[ ]*\r)/gi, '$1$3 $2$4');
 
//Month+day_number "March 7th" -> "March 7"
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd)([^\w\d][^\d]|[ ]*\r)/gi, '$1$2 $3$4');
 
//add comma when missing
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May\.?|Jun(?:e|\.|)|Jul(?:y|\.|)|Aug(?:ust|\.|)|Sep(?:tember|\.|t\.|)|Oct(?:ober|\.|)|Nov(?:ember|\.|)|Dec(?:ember|\.|))\s([0-32]?\d|30|31)(?:th|st|nd|rd|)(\s\d{1,4}[^\w\d][^\d])/gi, '$1$2 $3,$4');
 
Ohc_remove_leading_zeros_from_nonlinked_dates ();
Line 537 ⟶ 532:
addOnloadHook(function () {
if(document.forms.editform) {
addPortletLink('p-tb', 'javascript:Ohc_all_dates_to_dmy()', 'AllALL dates to dmy', 'ca-unitfixer', 'FixesAlign someall unitdates formattingto dmy', '', '');
addPortletLink('p-tb', 'javascript:Ohc_all_dates_to_mdy()', 'AllALL dates to mdy', 'ca-unitfixer', 'FixesAlign someall unitdates formattingto mdy', '', '');
addPortletLink('p-tb', 'javascript:Ohc_body_to_dmy()', 'Body dates to dmy', 't-dmy', 'day month', '', '');
addPortletLink('p-tb', 'javascript:Ohc_body_to_mdy()', 'Body dates to mdy', 't-mdy', 'month day', '', '');