User:Trappist the monk/MOSNUM dates.js test

This is a test and demonstration page intended to check changes made to User:Trappist the monk/script/MOSNUM dates.js in support of auto date formatting; see Help talk:Citation Style 1. Diff between User:Ohconfucius/script/MOSNUM dates.js script and this new version is here. These changes being acceptable, and auto date formatting provided by Module:Citation/CS1 and subsidiary modules, the changes implemented in User:Trappist the monk/script/MOSNUM dates.js need to be migrated to User:Ohconfucius/script/MOSNUM dates.js.

The current version of User:Ohconfucius/script/MOSNUM dates.js overwrites any existing and  templates (and their aliases) with a new template that specifies date format and has the current month and year in date. Any other parameters are discarded. Because the cs1|2 modules need to know details more fine-grained than  or , it is proposed that the  accept another parameter cs1-dates. To use this new parameter, User:Ohconfucius/script/MOSNUM dates.js must be tweaked so that it does not discard cs1-dates.

The new code does this:
 * 1) normalizes the use dates template name to the canonical form: of  where   is the text string   or   from the function argument   and where the name is stripped of leading and trailing whitespace
 * 2) searches the wikitext for  where   is either of the strings   or
 * when found (because the template name was normalized in step 1) continues to step 3
 * when not found, adds a new to the top of wikitext where   is the text string   or   from the function argument   and   is the current date's month and year; function exits
 * 1) replaces value assigned to date; reorders parameters to datecs1-dates order when both are present; inserts date if missing; cs1-dates and assigned value retain as is; function exits.

To install User:Trappist the monk/script/MOSNUM dates.js do these things:
 * 1) open [ your common.js in edit mode]
 * add:
 * 1) save and refresh

The testable bits of this page are invisible. To test User:Trappist the monk/script/MOSNUM dates.js:
 * 1) open this page in source edit mode (I don't know if this (or the original) script works with ve because I don't use ve)
 * 2) from the left panel under tools click 'ALL dates to dmy' (or one of the other appropriate links – see script documentation)
 * 3) inspect the diff; comments in the source explain what you should be seeing

No need to save the results; if you do, please revert.

This code change only modifies that part of the original script that handles the templates (or their redirects). The changes are confined to function.

All dates in this test page are January 2017 so new dates in the after a test should all be

To test the script's ability to insert a new template when there are none
 * 1) edit a page that doesn't (my talk page will work)
 * 2) from the left panel under tools click 'ALL dates to dmy' (or one of the other appropriate links – see script documentation)
 * 3) inspect the diff; comments in the source explain what you should be seeing

Again no need to save; if you do, please revert.