Content deleted Content added
Ohconfucius (talk | contribs) |
Ohconfucius (talk | contribs) indeed, the parameter is "cs1-dates" |
||
(37 intermediate revisions by 10 users not shown) | |||
Line 1:
{{Editnotice
| id = userpageedn
| header = New Features as of 26 June 2025
| headerstyle = font-size: 150%;
| text = Hello! the user script [[User:Ohconfucius/script/MOSNUM_dates.js]] has been updated to add new features in further support of [[WP:MOSNUM]] in articles. Two new functions have been added: <code>DMY_cs1=ly</code> and <code>MDY_cs1=ly</code> where dates in the body of the text (and publication dates within citation templates, plus all "loose dates" inside references) are converted to DMY or MDY; access dates and archive dates align to ymd (1978-07-14); adds template parameter {{para|cs1-dates}} with a matching value "ly".
Users are reminded to respect the [[WP:RETAIN|existing format in place]] and abide by [[WP:CONSENSUS]] when using this script.
{{Message▼
| textstyle = font-size: 120%;
| image = File:New-Bouncywikilogo.gif
| imagesize = 90px
| style = border:DarkRed solid 2px; background:var(--background-color-neutral,white); color:var(--color-base,black);
▲}}{{Message
| bgcolor = lightblue
| border-color = royalblue
Line 7 ⟶ 17:
| message = bug report or suggestion
| link = Wikipedia:Date formattings/script/MOSNUM dates/bugs
| extra-style = extra styles, like border-radius, etc...
| width =
| margin = 10px
| padding = 20px
| text-align = left
}}
}}{{shortcut|WP:Mosnumscript|WP:MOSNUMscript}}▼
[[File:Screen Shot 2014-02-04 at 00.29.33.png|thumb|280px|Sidebar ___location of the script buttons after you have clicked on the 'Tools' triangle]]▼
==Overview==▼
▲[[File:
This script delinks all dates and date fragments, and converts them all to the same format, either dd mmm yyyy ("14 July 1978") or mmm dd, yyyy ("July 14, 1978"). ▼
▲== Overview ==
▲This script delinks all dates and date fragments
MOSNUM allows one other format to be used in articles – but only in tables and reference sections.
<!-- '''''NOTE:''' Functions converting dates within citation templates has been withdrawn now that
There are modes that allow the user to select whether to treat body dates only or body and reference sections:
# '''
# '''
# '''DMY_cs1=ly''' – dates in the body of the text are converted to dmy ("14 July 1978" or similar); access dates and archive dates to ymd (1978-07-14); adds template parameter {{para|cs1-dates}} with a matching value "ly".
# '''MDY_cs1=ly''' – as above. prose and publication dates are aligned to mdy ("July 14, 1978" or similar); access dates and archive dates to ymd (1978-07-14); adds template parameter {{para|cs1-dates}} with a matching value "ly".
In addition, there are the following
<!--
# '''
# '''
-->#'''US-slash dates''' – converts dates that use slash or decimal separators in formats commonly used in the
▲In addition, there are the following six modes to convert slash or contracted dates into the desired format:
# '''UK-slash dates''' – converts dates that use slash or decimal separators in formats commonly used in the UK, Europe and elsewhere into '''dmy''' dates ''viz'': <code>dd/mm/yy</code>, <code>dd/mm/yyyy</code>, <code>dd.mm.yy</code> or <code>dd.mm.yyyy</code>▼
''* '''Note''': In these latter
▲#'''US-slash dates''' – converts dates that use slash or decimal separators in formats commonly used in the USA into '''mdy''' dates ''viz'': <code>mm/dd/yy</code>, <code>mm/dd/yyyy</code>, <code>mm.dd.yy</code> or <code>mm.dd.yyyy</code>
▲#'''UK-slash dates''' – converts dates that use slash or decimal separators in formats commonly used in the UK, Europe and elsewhere into '''dmy''' dates ''viz'': <code>dd/mm/yy</code>, <code>dd/mm/yyyy</code>, <code>dd.mm.yy</code> or <code>dd.mm.yyyy</code>
▲''*'''Note''': In these latter 4 cases, false positives are more likely because the protection mechanism of the script is bypassed, meaning the regex will act on dates in instances other than where the {{para|date}} parameter is used''
== History ==
Lightmouse initially created a script to deal with a number of general formatting issues, and date alignment was one such function. I used it and often gave feedback and bug reports. Seeing the need to work on the diversity of date formats and date situations that are seen here on Wikipedia, I created an independent script targeted at dates with some help and advice from Lightmouse.
Over the years, this script has been built on and refined.
== Detailed functional overview ==
* It is aimed to make displayed dates fully compatible with [[Wikipedia:Manual of Style (dates and numbers)]] (WP:MOSNUM)▼
* It ensures uniform presentation of dates within any given article. As such, it:▼
** delinks all dates and date fragments, including day-month strings, days, months, decades, centuries,▼
** converts all these date fragments to the same format, either dd mmm yyyy or mmm dd, yyyy, at the option of the user▼
** yyyy-mmm-dd dates within accessdate and archivedate are not acted upon, but inconsistent (out of place) dates – dd mmm yyyy or mmm dd, yyyy will be converted.
** removes ordinal suffixes and constructions such as '<
** adds commas where necessary (e.g. February 28, 2001) ▼
** removes redundant commas (e.g. July<
* It removes <s>year linking templates (such as {{tl|scy}}, {{tl|by}}), and</s> links to 'year-in X' where piped from years (such as <nowiki>[[1984 in literature|1984]]</nowiki>)▼
* It converts other often used (but not MOSNUM-compliant) date formats within the references section, such as dd-mm-yyyy or dd-mmm-yyyy to the chosen prevailing format used in the rest of the article.▼
* It makes certain fixes that may be identified as [[:Category:CS1 errors: dates|CS1 dates errors]]
* cs1=ly buttons, of which there are two, insert the eponymous template parameters, and will convert underlying dates within {{para|accessdate}} and {{para|archivedate}} to ymd.
<!-- * ISO-style dates (yyyy-mm-dd) which are outside <nowiki><ref></ref></nowiki> tags are not acted upon by the script -->▼
▲The dates script is at '''[[User:Ohconfucius/script/MOSNUM dates.js]]'''.
▲*It is aimed to make displayed dates fully compatible with [[Wikipedia:Manual of Style (dates and numbers)]] (WP:MOSNUM)
▲*It ensures uniform presentation of dates within any given article. As such, it:
▲**delinks all dates and date fragments, including day-month strings, days, months, decades, centuries,
▲**converts all these date fragments to the same format, either dd mmm yyyy or mmm dd, yyyy, at the option of the user
▲**removes ordinal suffixes and constructions such as '<font color=orange>the</font> 5<font color=orange>th of</font> September', 'December 25<font color=orange>th</font>' or 'October <font color=orange>of</font> 2003'
▲**adds commas where necessary (e.g. February 28 2001)
▲**removes redundant commas (e.g. July<font color=orange>,</font> 1997; 28 February<font color=orange>,</font> 2001)
▲*It removes direct links to dates, and most form of piped date links
▲*It removes year linking templates (such as {{tl|scy}}, {{tl|by}}), and links to 'year-in X' where piped from years (such as <nowiki>[[1984 in literature|1984]]</nowiki>)
▲*It converts other often used (but not MOSNUM-compliant) date formats within the references section, such as dd-mm-yyyy or dd-mmm-yyyy to the chosen prevailing format used in the rest of the article.
▲<!-- *ISO-style dates (yyyy-mm-dd) which are outside <nowiki><ref></ref></nowiki> tags are not acted upon by the script
The script adds or updates a non-displaying template {{tl|use mdy dates}} or {{tl|use dmy dates}} depending on the conversion used. This tagging allows for WM software engine to render date formats automatically in conformity with tagged format). It also facilitates future maintenance by bot by script [[WP:AWB|AWB]].
The script will achieve overall consistency of the '''format''' of the date<!-- , but will ''not'' alter the '''form''' (i.e. month spelt out in full or abbreviated to 3 or 4 letters. This task is assured by 'Expand ref dates', 'Expand all dates' and 'Abbrev ref dates' functions -->. The format and syntax of citations were modelled after the way reference sections are rendered when using the most common citation templates – {{tl|cite news}} and {{tl|cite web}}; I try to stick to syntax in <nowiki>{{cite web}}</nowiki> where 'Retrieved' is capitalised and preceded by a full-stop.
Although the MediaWiki software interprets {{tl|use dmy dates}} or {{tl|use mdy dates}} templates, allowing dates and access dates within citation templates to be automatically formatted, errors there and elsewhere may still require correction. The script takes care of that.
=== How it works ===
Line 75 ⟶ 81:
As also mentioned [[#Known_limitations|below]], the actions of the protection mechanism can be revealed in the event of the script stalling, and substitution markers may appear in the edit window. When this occurs, the user should abandon the action, reopen the edit window and reperform the edit.
=== Optional auto-formatting citation template dates ===
Script default is without parameter all dates are aligned to the prevailing style indicated – dmy or mdy.
Notwithstanding the available buttons, [[Help:Citation Style 1|Citation Style 1]] and [[Help:Citation Style 2|2]] (collectively cs1|2) templates can be configured to render dates ({{para|date}}, {{para|access-date}}, {{para|archive-date}}, etc) in the style specified by this template as permitted by [[WP:MOSDATES]].
{{#lst:Help:Citation Style 1|auto_date_format_table}}
An example is given at {{section link|Help:Citation Style 1#Auto-formatting citation template dates}}.
=== Credits ===
Line 83 ⟶ 97:
{{User:Ohconfucius/script/install}}
== Actions and test ==
'''Use of the [[Safari (web browser)|''Safari'']] or ''[[Firefox]]'' browsers is highly recommended'''. It only functions in desktop mode.
The script is continually being run
The tool may also be used on mobile browsers. However,
Once you are in edit mode, there are buttons in the toolbox in the left margin:
#'''DATES to dmy'''{{snd}}converts all dates to ''{{date|{{date}}|dmy}}'' dmy format
#'''DATES to mdy'''{{snd}}converts all dates to ''{{date|{{date}}|mdy}}'' mdy format
#'''US-slash dates''' – converts all applicable dates into ''{{date|{{date}}|mdy}}'' mdy format
#'''UK-slash dates''' – converts all applicable dates into ''{{date|{{date}}|dmy}}'' dmy format
Line 105 ⟶ 116:
<blockquote>
===== Format consistency =====
* Dates in article body text should all use the same format: Julia ate a poisoned apple on 25 June 2005, and died on 28 June (not ... on June 28).
* Publication dates in references should all use the same format. Any format from the "Acceptable date formats" table above may be used
* Access and archive dates in references should all use the same format – either the format used for publication dates
(These consistency requirements apply to dates in general prose and reference citations, but not to dates in quotations or titles)
===== Strong national ties to a topic =====
{{shortcut|WP:STRONGNAT|WP:TIES}}
* Articles on topics with strong ties to a particular English-speaking country should generally use the more common date format for that nation. For the United States, this is month before day; for most others, it is day before month. Articles related to Canada may use either format consistently.
* Sometimes the customary format differs from the usual national one: for example, articles on the modern US military use day before month, in accordance with military usage.
===== Retaining the existing format =====
{{shortcut|WP:RETAIN}}
* If an article has evolved using predominantly one format, the whole article should conform to it, unless there are reasons for changing it based on strong national ties to the topic or consensus on article talk.
* The date format chosen by the first major contributor in the early stages of an article should continue to be used, unless there is reason to change it based on strong national ties to the topic or consensus on article talk.
Line 125 ⟶ 138:
==== Test pages ====
* [[User:Full-date unlinking bot/Test environment]] - tests unlinking and dmy<–>mdy conversion
* [[User:Dl2000/testtemp7]] - slash dates
* [[User:Ohconfucius/MOSNUM script test]] – test page dealing with [[Help:CS1 errors|CS1 date errors]]
===Known limitations===▼
▲=== Known limitations ===
* '''Proper nouns with dates''': A number of proper nouns containing date fragments (such as '[[:March 14 Alliance]]', '[[:6th of October City]]', '[[:June 1, 1974]]', '[[:2000 AD]]') have been specifically protected from conversion or delinking. Only the displayed part of piped links are acted upon, whilst the underlying pipe will not be changed. For the purposes of this script, [[:September 11]] or [[:September 11 attacks]] ''is'' treated: there are ample redirects in existence for any problems to be mitigated. '''Let me know if there are other proper names which ought to be protected'''.
* '''Dates that are used as adjectives''': Because the script routinely removes the leading "the" for dates, attention should be paid to where the date is used as an adjective, such as "<
<!-- * '''"body dates" functions''': When these two functions are run, the script protects all within <nowiki><ref></ref></nowiki> tags, so that no dates within citations will be changed, '''even if they are incorrect''' (ie mdy in dmy articles and vice versa). As a consequence, there are corrections the full script makes dates such as missing commas (eg Sept 27 2013), extra commas (eg 27 Sept, 2013) or misspelt month names or missing capitalisation (eg 2 mars 2013), which will not happen with these functions. ''For the above reason, the function – which has been disabled once and restated due to a specific request – may be withdrawn permanently in due course.'' -->
* '''Stalling''': If you see characters such as the following in your diffs window, don't panic:
Line 141 ⟶ 154:
==== Other Wiki scripts or gadgets ====
* '''wikEd''': The script is known to conflict with ''[[User:Cacycle/wikEd|wikEd]]'' that prevents the ''MOSNUM dates'' script from making ''any'' changes to articles, or simply blocking the creation of a script button. The solution is to toggle the ''wikEd text area'' '''''off''''' while running'' MOSNUM dates''. ''wikEd'' has an easy toggle button for that called: ''Use wikEd instead of classic text area''. Simply press the toggle button so the button pops out (off), then run ''MOSNUM dates''. When you are done running ''MOSNUM dates'' you can press the toggle button again so the toggle button pops in (on) and the ''wikEd text area'' will be live again. Once you get in the habit of toggling the ''wikEd text area'' '''''on''''' and '''''off''''', running ''MOSNUM dates'' is no longer a conflict with ''wikEd''. There is no need to disable/re-enable wikEd in your common.js file.
==== Browsers ====
* It has [https://en.wikipedia.org/w/index.php?title=User_talk:Ohconfucius&oldid=776359500#MOSNUM_script been reported] that Chrome extension "[[Privacy Badger]]" may somehow inhibit the script functioning.
== Disclaimers ==
I use and make experimental changes to another version, and update this production version regularly to a suitably stable prior version of the test script. However, like all software, bugs are unavoidable. Use at your own risk, and make sure you '''check the edit changes before you save'''. The script is continually being run
By consensus, this script should not be used in articles about chronological periods, such as [[:2015]] or [[January 25]], as date links here, considered desirable, would otherwise be automatically removed. Equally, I suspect that using the script on talk pages or on WP pages is likely to result in more angst than benefit to the project.
== See also ==
* [[Wikipedia:User scripts]]
* [[Wikipedia:Date formattings]]
|