User:Gimmetrow/dates.js

In User:Gimmetrow/dates.js's article, we will thoroughly explore all facets of this topic. From its origin to its evolution over time, through its impact on society and its relevance today. We will analyze different perspectives and opinions from experts in the field, as well as relevant data that will help to better understand the importance and influence of User:Gimmetrow/dates.js in different areas. This article seeks to provide a complete and detailed view of User:Gimmetrow/dates.js, with the aim of enriching knowledge and promoting critical reflection on this topic.
//<pre><code>
//

function mosdate() {
   var txt = document.editform.wpTextbox1;
   txt.value = txt.value

   //MOSDATE remove th in dates followed by -th, others
    //.replace(/()(January|February|March|April|May|June|July|August|September|October|November|December)\s(\d\d?)(th|st|nd|rd)/gi, '$1]')
    .replace(/(January|February|March|April|May|June|July|August|September|October|November|December)\s(\d\d?)(th|st|nd|rd)/gi, '$1 $2')
    .replace(/\\](<sup>)?(th|st|nd|rd)(<\/sup>)?/gi, ']') 
    .replace(/(\D\d\d?)(<sup>)?(th|st|nd|rd)(<\/sup>)?\s(January|February|March|April|May|June|July|August|September|October|November|December)/gi, '$1 $5')
    .replace(/\s(\d{3}0)'s(\W)/gi, ' $1s$2')
    .replace(/the\s(January|February|March|April|May|June|July|August|September|October|November|December)\sof\s(\d{4})/gi, '$1 $2')
    .replace(/(January|February|March|April|May|June|July|August|September|October|November|December)\sof\s(\d{4})/gi, '$1 $2')
    .replace(/the\s(\d\d?)(th|st|nd|rd)\sof\s(January|February|March|April|May|June|July|August|September|October|November|December)/gi, '$3 $1')
    .replace(/(\d\dth\s)Century/g, '$1century')
    .replace(/20th century()(Fox|Pictures|Limited|Film|Frog)/g, '20th Century$1$2');
}

function accessISO() {
   var txt = document.editform.wpTextbox1;
   txt.value = txt.value
   .replace(/(\|*accessdate*=*)(|) (January|Jan\.|Jan),? *()/g, "$1$4-01-$2")
   .replace(/(\|*accessdate*=*)(January|Jan\.|Jan) (|),? *()/g, "$1$4-01-$3")
   .replace(/(\|*accessdate*=*)(|) (February|Feb\.|Feb),? *()/g, "$1$4-02-$2")
   .replace(/(\|*accessdate*=*)(February|Feb\.|Feb) (|),? *()/g, "$1$4-02-$3")
   .replace(/(\|*accessdate*=*)(|) (March|Mar\.|Mar),? *()/g, "$1$4-03-$2")
   .replace(/(\|*accessdate*=*)(March|Mar\.|Mar) (|),? *()/g, "$1$4-03-$3")
   .replace(/(\|*accessdate*=*)(|) (April|Apr\.|Apr),? *()/g, "$1$4-04-$2")
   .replace(/(\|*accessdate*=*)(April|Apr\.|Aor) (|),? *()/g, "$1$4-04-$3")
   .replace(/(\|*accessdate*=*)(|) (May|May\.),? *()/g, "$1$4-05-$2")
   .replace(/(\|*accessdate*=*)(May|May\.) (|),? *()/g, "$1$4-05-$3")
   .replace(/(\|*accessdate*=*)(|) (June|Jun\.|Jun),? *()/g, "$1$4-06-$2")
   .replace(/(\|*accessdate*=*)(June|Jun\.|Jun) (|),? *()/g, "$1$4-06-$3")
   .replace(/(\|*accessdate*=*)(|) (July|Jul\.|Jul),? *()/g, "$1$4-07-$2")
   .replace(/(\|*accessdate*=*)(July|Jul\.|Jul) (|),? *()/g, "$1$4-07-$3")
   .replace(/(\|*accessdate*=*)(|) (August|Aug\.|Aug),? *()/g, "$1$4-08-$2")
   .replace(/(\|*accessdate*=*)(August|Aug\.|Aug) (|),? *()/g, "$1$4-08-$3")
   .replace(/(\|*accessdate*=*)(|) (September|Sept\.|Sept|Sep\.|Sep),? *()/g, "$1$4-09-$2")
   .replace(/(\|*accessdate*=*)(September|Sept\.|Sept|Sep\.|Sep) (|),? *()/g, "$1$4-09-$3")
   .replace(/(\|*accessdate*=*)(|) (October|Oct\.|Oct),? *()/g, "$1$4-10-$2")
   .replace(/(\|*accessdate*=*)(October|Oct\.|Oct) (|),? *()/g, "$1$4-10-$3")
   .replace(/(\|*accessdate*=*)(|) (November|Nov\.|Nov),? *()/g, "$1$4-11-$2")
   .replace(/(\|*accessdate*=*)(November|Nov\.|Nov) (|),? *()/g, "$1$4-11-$3")
   .replace(/(\|*accessdate*=*)(|) (December|Dec\.|Dec),? *()/g, "$1$4-12-$2")
   .replace(/(\|*accessdate*=*)(December|Dec\.|Dec) (|),? *()/g, "$1$4-12-$3");
}

function ISOtodmy() {
   var txt = document.editform.wpTextbox1;

   txt.value = txt.value.replace(/\--)\]\]/g, "$1");
   txt.value = txt.value.replace(/\)\]\]-\-)\]\]/g, "$1-$2");

   //txt.value = txt.value.replace(/accesse?date*=*/gi, "QQQaccessdateQQQ"); // avoid, but fix a quirk
   //txt.value = txt.value.replace(/accessed+/g, "QQQaccessedQQQ"); // avoid
   //txt.value = txt.value.replace(/Accessed+/g, "QQQAccessedQQQ"); // avoid

   txt.value = txt.value
   .replace(/(\|*date*=*)()-01-0()()/g, "$1$3 January $2$4")
   .replace(/(\|*date*=*)()-02-0()()/g, "$1$3 February $2$4")
   .replace(/(\|*date*=*)()-03-0()()/g, "$1$3 March $2$4")
   .replace(/(\|*date*=*)()-04-0()()/g, "$1$3 April $2$4")
   .replace(/(\|*date*=*)()-05-0()()/g, "$1$3 May $2$4")
   .replace(/(\|*date*=*)()-06-0()()/g, "$1$3 June $2$4")
   .replace(/(\|*date*=*)()-07-0()()/g, "$1$3 July $2$4")
   .replace(/(\|*date*=*)()-08-0()()/g, "$1$3 August $2$4")
   .replace(/(\|*date*=*)()-09-0()()/g, "$1$3 September $2$4")
   .replace(/(\|*date*=*)()-10-0()()/g, "$1$3 October $2$4")
   .replace(/(\|*date*=*)()-11-0()()/g, "$1$3 November $2$4")
   .replace(/(\|*date*=*)()-12-0()()/g, "$1$3 December $2$4");

   txt.value = txt.value
   .replace(/(\|*date*=*)()-01-()()/g, "$1$3 January $2$4")
   .replace(/(\|*date*=*)()-02-()()/g, "$1$3 February $2$4")
   .replace(/(\|*date*=*)()-03-()()/g, "$1$3 March $2$4")
   .replace(/(\|*date*=*)()-04-()()/g, "$1$3 April $2$4")
   .replace(/(\|*date*=*)()-05-()()/g, "$1$3 May $2$4")
   .replace(/(\|*date*=*)()-06-()()/g, "$1$3 June $2$4")
   .replace(/(\|*date*=*)()-07-()()/g, "$1$3 July $2$4")
   .replace(/(\|*date*=*)()-08-()()/g, "$1$3 August $2$4")
   .replace(/(\|*date*=*)()-09-()()/g, "$1$3 September $2$4")
   .replace(/(\|*date*=*)()-10-()()/g, "$1$3 October $2$4")
   .replace(/(\|*date*=*)()-11-()()/g, "$1$3 November $2$4")
   .replace(/(\|*date*=*)()-12-()()/g, "$1$3 December $2$4");

   //txt.value = txt.value.replace(/QQQaccessdateQQQ/g, "accessdate=");
   //txt.value = txt.value.replace(/QQQaccessedQQQ/g, "accessed ");
   //txt.value = txt.value.replace(/QQQAccessedQQQ/g, "Accessed ");
}

function ISOtomdy() {
   var txt = document.editform.wpTextbox1;

   txt.value = txt.value.replace(/\--)\]\]/g, "$1");
   txt.value = txt.value.replace(/\)\]\]-\-)\]\]/g, "$1-$2");

   //txt.value = txt.value.replace(/accesse?date*=*/gi, "QQQaccessdateQQQ"); // avoid, but fix a quirk
   //txt.value = txt.value.replace(/accessed+/g, "QQQaccessedQQQ"); // avoid
   //txt.value = txt.value.replace(/Accessed+/g, "QQQAccessedQQQ"); // avoid

   txt.value = txt.value
   .replace(/(\|*date*=*)()-01-0()()/g, "$1 January $3, $2$4")
   .replace(/(\|*date*=*)()-02-0()()/g, "$1February $3, $2$4")
   .replace(/(\|*date*=*)()-03-0()()/g, "$1March $3, $2$4")
   .replace(/(\|*date*=*)()-04-0()()/g, "$1April $3, $2$4")
   .replace(/(\|*date*=*)()-05-0()()/g, "$1May $3, $2$4")
   .replace(/(\|*date*=*)()-06-0()()/g, "$1June $3, $2$4")
   .replace(/(\|*date*=*)()-07-0()()/g, "$1July $3, $2$4")
   .replace(/(\|*date*=*)()-08-0()()/g, "$1August $3, $2$4")
   .replace(/(\|*date*=*)()-09-0()()/g, "$1September $3, $2$4")
   .replace(/(\|*date*=*)()-10-0()()/g, "$1October $3, $2$4")
   .replace(/(\|*date*=*)()-11-0()()/g, "$1November $3, $2$4")
   .replace(/(\|*date*=*)()-12-0()()/g, "$1December $3, $2$4");

   txt.value = txt.value
   .replace(/(\|*date*=*)()-01-()()/g, "$1January $3, $2$4")
   .replace(/(\|*date*=*)()-02-()()/g, "$1February $3, $2$4")
   .replace(/(\|*date*=*)()-03-()()/g, "$1March $3, $2$4")
   .replace(/(\|*date*=*)()-04-()()/g, "$1April $3, $2$4")
   .replace(/(\|*date*=*)()-05-()()/g, "$1May $3, $2$4")
   .replace(/(\|*date*=*)()-06-()()/g, "$1June $3, $2$4")
   .replace(/(\|*date*=*)()-07-()()/g, "$1July $3, $2$4")
   .replace(/(\|*date*=*)()-08-()()/g, "$1August $3, $2$4")
   .replace(/(\|*date*=*)()-09-()()/g, "$1September $3, $2$4")
   .replace(/(\|*date*=*)()-10-()()/g, "$1October $3, $2$4")
   .replace(/(\|*date*=*)()-11-()()/g, "$1November $3, $2$4")
   .replace(/(\|*date*=*)()-12-()()/g, "$1December $3, $2$4");

   //txt.value = txt.value.replace(/QQQaccessdateQQQ/g, "accessdate=");
   //txt.value = txt.value.replace(/QQQaccessedQQQ/g, "accessed ");
   //txt.value = txt.value.replace(/QQQAccessedQQQ/g, "Accessed ");
}

function riskyISO() {
   var txt = document.editform.wpTextbox1;

   txt.value = txt.value.replace(/\--)\]\]/g, "$1");

   txt.value = txt.value
   .replace(/()()-01-0()()/g, "$1$3 January $2$4")
   .replace(/()()-02-0()()/g, "$1$3 February $2$4")
   .replace(/()()-03-0()()/g, "$1$3 March $2$4")
   .replace(/()()-04-0()()/g, "$1$3 April $2$4")
   .replace(/()()-05-0()()/g, "$1$3 May $2$4")
   .replace(/()()-06-0()()/g, "$1$3 June $2$4")
   .replace(/()()-07-0()()/g, "$1$3 July $2$4")
   .replace(/()()-08-0()()/g, "$1$3 August $2$4")
   .replace(/()()-09-0()()/g, "$1$3 September $2$4")
   .replace(/()()-10-0()()/g, "$1$3 October $2$4")
   .replace(/()()-11-0()()/g, "$1$3 November $2$4")
   .replace(/()()-12-0()()/g, "$1$3 December $2$4");

   txt.value = txt.value
   .replace(/()()-01-()()/g, "$1$3 January $2$4")
   .replace(/()()-02-()()/g, "$1$3 February $2$4")
   .replace(/()()-03-()()/g, "$1$3 March $2$4")
   .replace(/()()-04-()()/g, "$1$3 April $2$4")
   .replace(/()()-05-()()/g, "$1$3 May $2$4")
   .replace(/()()-06-()()/g, "$1$3 June $2$4")
   .replace(/()()-07-()()/g, "$1$3 July $2$4")
   .replace(/()()-08-()()/g, "$1$3 August $2$4")
   .replace(/()()-09-()()/g, "$1$3 September $2$4")
   .replace(/()()-10-()()/g, "$1$3 October $2$4")
   .replace(/()()-11-()()/g, "$1$3 November $2$4")
   .replace(/()()-12-()()/g, "$1$3 December $2$4");

   //txt.value = txt.value.replace(/QQQaccessdateQQQ/g, "accessdate=");
   //txt.value = txt.value.replace(/QQQaccessedQQQ/g, "accessed ");
   //txt.value = txt.value.replace(/QQQAccessedQQQ/g, "Accessed ");
}

function yearinX() {
   var monthyear = new RegExp("\\)\\]\\]", "g");
   var txt = document.editform.wpTextbox1;
   txt.value = txt.value.replace(/\ in +\|()\]\]/g, "]");
   txt.value = txt.value.replace(/(] | ])\)\]\]/g, "$1$2");
   txt.value = txt.value.replace(monthyear, "$1 $2");
}

function dayMonth(option) {
   var daymonth = new RegExp("\\|) (January|February|March|April|May|June|July|August|September|October|November|December)\\]\\],? *\\)\\]\\]", "g");
   var monthday = new RegExp("\\|)\\]\\],? *\\)\\]\\]", "g");
   var daymonth2 = new RegExp("\\|) (January|February|March|April|May|June|July|August|September|October|November|December)\\]\\]", "g");
   var monthday2 = new RegExp("\\|)\\]\\]", "g");

   var txt = document.editform.wpTextbox1;
   if (option == 1) {
      // dd Month
      txt.value = txt.value.replace(monthday , "] ]");
      txt.value = txt.value.replace(daymonth , "] ]");
      txt.value = txt.value.replace(monthday2, "]");
      txt.value = txt.value.replace(daymonth2, "]");
   } else {
      // Month dd
      txt.value = txt.value.replace(monthday , "], ]");
      txt.value = txt.value.replace(daymonth , "], ]");
      txt.value = txt.value.replace(monthday2, "]");
      txt.value = txt.value.replace(daymonth2, "]");
   }
}

function addDLinks() {
   var daymonth = new RegExp("(|) (January|February|March|April|May|June|July|August|September|October|November|December),? *()", "g");
   var monthday = new RegExp("(January|February|March|April|May|June|July|August|September|October|November|December) (|),? *()", "g");
   var daymonth2 = new RegExp("\\|) (January|February|March|April|May|June|July|August|September|October|November|December)\\]\\],? *()", "g");
   var monthday2 = new RegExp("\\|)\\]\\],? *()", "g");
   var daymonth3 = new RegExp("()(|) (January|February|March|April|May|June|July|August|September|October|November|December)(])", "g");
   var monthday3 = new RegExp("()(January|February|March|April|May|June|July|August|September|October|November|December) (|)(])", "g");
   var txt = document.editform.wpTextbox1;
   txt.value = txt.value.replace(monthday, "], ]");
   txt.value = txt.value.replace(daymonth, "] ]");
   txt.value = txt.value.replace(monthday2, "], ]");
   txt.value = txt.value.replace(daymonth2, "] ]");
   txt.value = txt.value.replace(monthday3, "$1]$4");
   txt.value = txt.value.replace(daymonth3, "$1]$4");
}

function remDLinks() {
   var daymonth = new RegExp("\\|) (January|February|March|April|May|June|July|August|September|October|November|December)\\]\\],? *\\)\\]\\]", "g");
   var monthday = new RegExp("\\|)\\]\\],? *\\)\\]\\]", "g");
   var daymonth3 = new RegExp("\\|) (January|February|March|April|May|June|July|August|September|October|November|December)\\]\\]", "g");
   var monthday3 = new RegExp("\\|)\\]\\]", "g");
   var txt = document.editform.wpTextbox1;
   txt.value = txt.value.replace(monthday, "$1 $2, $3");
   txt.value = txt.value.replace(daymonth, "$1 $2 $3");
   txt.value = txt.value.replace(monthday3, "$1 $2");
   txt.value = txt.value.replace(daymonth3, "$1 $2");
}

addOnloadHook(function () {
    if(document.forms.editform) {
        mw.util.addPortletLink('p-tb', 'javascript:mosdate()'  , 'Format mosdate   ', 't-mosdate',  'Regexp mosdate', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:ISOtodmy()' , 'Format ISO->dmy  ', 't-ISOtodmy', 'Regexp ISOtodmy', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:ISOtomdy()' , 'Format ISO->mdy  ', 't-ISOtomdy', 'Regexp ISOtomdy', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:accessISO()', 'Format acd->ISO  ', 't-acdtoISO', 'Regexp acdtoISO', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:riskyISO()' , 'Format riskyISO  ', 't-riskyISO', 'Regexp riskyISO', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:yearinX()'  , 'Format -year in X', 't-yearinX',  'Regexp yearinX', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:addDLinks()', 'Format +datelinks', 't-addlinks', 'Regexp links', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:dayMonth(1)', '=Format \]', 't-daymonth', 'Regexp day month', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:dayMonth(2)', '=Format \]', 't-monthday', 'Regexp month day', '', '');
        mw.util.addPortletLink('p-tb', 'javascript:remDLinks()', 'Format -datelinks', 't-remlinks', 'Regexp links', '', '');
    }
});
//</code></pre>