Content deleted Content added
Ohconfucius (talk | contribs) November |
Ohconfucius (talk | contribs) 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
function Ohc_fix_common_errors() {
var txt=document.editform.wpTextbox1;
protect_dates_in_titles();
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');▼
//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-
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-
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
//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-
txt.value=txt.value.replace(/(\((?:file|image|img)[
txt.value=txt.value.replace(/((?:file|image|img)[
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-
txt.value=txt.value.replace(/([0-
//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|\.|))([^\|]
//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 $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-
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-
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-
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-
txt.value=txt.value.replace(/
//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|))([^\
//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 $5 $6$7');
}
Line 102 ⟶ 91:
txt.value=txt.value.replace(/\[\[(\d{4})\]\]-([0-1]\d-[0-3]\d)/gi, '$1-$2');
//delink full dates
txt.value=txt.value.replace(/
txt.value=txt.value.replace(/
//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]]'
//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-
//dmy birth and death date ranges)
txt.value=txt.value.replace(/([^\d][^\w\d])([0-
}
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(/(March )((?:8|14) Alliance)/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\
}
Line 294 ⟶ 288:
//unprotect certain dates
txt.value=txt.value.replace(/(\[\[4)♫(AD)/gi, '$1♫$2');
txt.value=txt.value.replace(/(\[\[(?:
txt.value=txt.value.replace(/(6th\sof\s)♫(October City)/gi, '$1$2');
txt.value=txt.value.replace(/(\
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|
if (txt.value.search(/{{
{
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
//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
//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
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
//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
//'md, md,' to 'dm, dm,'
txt.value=txt.value.replace(/([^\d])( (Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
//convert simple mdy dates to dmy
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
▲ 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-
txt.value=txt.value.replace(/([^\d][^\w\d])([0-
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(/{{
{
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-
//convert dm-dmy date ranges to md-mdy
txt.value=txt.value.replace(/([^\d][^\w\d])(
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-
txt.value=txt.value.replace(/([^\d][^\w\d])((?:[0-3]?\d(?:th|st|nd|rd|),?[\s]{1,3}){1,6})([0-
//convert dm date ranges to md (simple, separated by hyphen, dash or 'to')
txt.value=txt.value.replace(/([^\d][^\w\d])([0-
//'dm, dm,' to 'md, md,'
txt.value=txt.value.replace(/([^\d])( [0-
▲ 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');
//Month+day_number "March 7th" -> "March 7"
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
//add comma when missing
txt.value=txt.value.replace(/([^\d][^\w\d])(Jan(?:uary|\.|)|Feb(?:ruary|\.|)|Mar(?:ch|\.|)|Apr(?:il|\.|)|May
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()', '
addPortletLink('p-tb', 'javascript:Ohc_all_dates_to_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', '', '');
|