Revision as of 14:25, 13 January 2016 editComp.arch (talk | contribs)Extended confirmed users40,316 editsmNo edit summary← Previous edit | Revision as of 21:06, 15 January 2016 edit undoWikiWikiWayne (talk | contribs)Extended confirmed users37,087 edits →Known limitations: add wikEd workaroundNext edit → | ||
Line 121: | Line 121: | ||
===Known limitations=== | ===Known limitations=== | ||
* A number of proper nouns containing date fragments (such as ']', ']', ']', ']') 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, ] or ] ''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'''. | * '''Proper nouns with dates''': A number of proper nouns containing date fragments (such as ']', ']', ']', ']') 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, ] or ] ''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 "<font color=orange>the</font> 6 June beach landings". The "the" should either be reinserted, or the phrase reconfigured so that the date is no longer adjectival (e.g. "the beach landings on 6 June"). | ||
* |
* '''Non-ISO-style date within citation''': The 'body dates' functions will act on any non-ISO-style date within citation, so that if there is a dmy date within references (amongst dates such as 2009-01-11), the former will be acted on by the mdy function whilst the latter will be unaffected. | ||
* There has been report of conflict with ] that may prevent this script from making any changes to articles. | |||
* '''wikEd''': There is a conflict with ] that prevents the MOSNUM script from making ''any'' changes to articles. The solution is to toggle the wikEd text area ''off'' while running MOSNUM. 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. When you are done running MOSNUM 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 is no longer a conflict with wikEd. There is no need to disable/re-enable wikEd in your common.js file. | |||
== Disclaimers == | == Disclaimers == |
Revision as of 21:06, 15 January 2016
Please leave a bug report or suggestion. |
Overview
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").
MOSNUM allows one other format to be used in articles – but only in tables and reference sections. Although the yyyy-mm-dd dates ("1978-07-14") used in Misplaced Pages are not actually fully ISO 8601-compliant, they are shorthanded in the sidebar button to "ISO" due to space constraints.
There are modes that allow the user to select whether to treat body dates only or body and reference sections:
- all dates to dmy – dates in the body of the text as well as in the reference sections are converted to "14 July 1978" or similar.
- all dates to mdy – as above. dates are converted to "July 14, 1978" or similar.
- body dates to dmy – no yyyy-mm-dd dates ("1978-07-14") converted
- body dates to mdy – no yyyy-mm-dd dates ("1978-07-14") converted
In addition, there are the following six modes to convert slash or contracted dates into the desired format:
- Del year-in-X dates – unlinks the most common 'year-in-X' links
- US-slash dates – resolves US style slash-dates (e.g. 7/27/1961, 07/27/1961, 07/27/61, 7/27/61), or dates using the full stop or hyphens as separator (e.g. 7.27.1961, 7.27.1961, 7.27.61, 7.27.61, 7-27-1961, 7-27-1961, 7-27-61, 7-27-61), into mdy format
- UK-slash dates – resolves UK/European style slash-dates (e.g. 27/7/1961, 27/07/1961, 27/07/61, 27/7/61), or dates using the full stop or hyphens as separator (e.g. 27.7.1961, 27.07.1961, 27.07.61, 27.7.61, 27-7-1961, 27-07-1961, 27-07-61, 27-7-61), into dmy format
- Expand ref dates – Expand month names within the references section
- Expand all dates – Expand month names elsewhere within the article
- Abbrev ref dates – Abbreviate month names within the references section
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 Misplaced Pages, 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. But it was getting unwieldy, and was getting slow, and harder and harder to maintain.
In April 2012, the engine underwent a major rework by 1exec1 (talk · contribs), who built it and incorporated a new regex_worker function that allows more effective treatment of date fragments; there is better protection of strings that ought not to be modified by the script. In May, the new improved version of the script went 'live'.
Overview
The dates script is at User:Ohconfucius/script/MOSNUM dates.js.
- It is aimed to make displayed dates fully compatible with Misplaced Pages: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 'the 5th of September', 'December 25th' or 'October of 2003'
- adds commas where necessary (e.g. February 28 2001)
- removes redundant commas (e.g. July, 1997; 28 February, 2001)
- It removes direct links to dates, and most form of piped date links
- It removes year linking templates (such as {{scy}}, {{by}}), and links to 'year-in X' where piped from years (such as ])
- 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 also allows users to choose to convert dates within only the body of the article, as is permitted for reference sections (where yyyy-mm-dd dates are common) to have different dates, or throughout the article.
- ISO-style dates (yyyy-mm-dd) which are outside <ref></ref> tags are not acted upon by the script
The script adds or updates a non-displaying template {{use mdy dates}} or {{use dmy dates}} depending on the conversion used. This tagging allows for easy future maintenance for anybody armed with 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 – {{cite news}} and {{cite web}}; I try to stick to syntax in {{cite web}} where 'Retrieved' is capitalised and preceded by a full-stop.
How it works
The script is configured so that dates are stored as an array. The given regex and substitution strings can contain magic words that specify what date format the routine should accept and to what date format the routine should convert the date to.
There is a mechanism in place to protect a wide range of strings that ought to be immutable: such as images, categories, urls; text within blockquotes and double quotes; text within certain parameters (e.g. |title=
).
Credits
I am solely responsible for this tool, which has been inspired by the dates scripts written by User:Lightmouse and User:Plastikspork. It incorporates many additional features, such as unlinking many unusually-piped date-links, conversion of date series and ranges, and delinking months of the year. Thanks also to User:1exec1 for the invaluable assistance in rewriting and simplifying the workings of the script in April 2012.
Feedback is appreciated at User Talk:Ohconfucius. Please report any false negatives as well as false positives you may detect.
Installing the script
- Open your common.js in edit mode (alternatively, go to your user page and append "/common.js" to the end of the URL and open the page in edit mode).
- If you prefer to load this only on a specific skin, such as monobook, open your monobook.js in edit mode.
- If you make a straight copy of this script, instead of "importing" it, you may not benefit from the enhancements and bug-fixes that are made from time to time. In the latter case, you may choose to watchlist this page so you will know when to update your copy for modifications to this script.
- Copy the following code onto the JavaScript page you have chosen in the previous step:
importScript('User:Ohconfucius/script/MOSNUM dates.js'); // ]
- Save the page and (re-)load it – refresh the cache by following the instructions at the top of your JavaScript page.
- Bookmark the script page. This will be your cue to purge the cache on your browser for any updates to take effect.
Disclaimer: Use at your own risk and make sure you check the edit changes before you save.
- If you have automatic userscript installation enabled, you can simply visit User:Ohconfucius/script/MOSNUM dates.js and click "Install" at the top of the page.
Actions and test
Use of the Safari or Firefox browsers is highly recommended.
The script is continually being run, and seems to work as intended on the latest Firefox and Chrome browsers on Mac and Windoze. On Windows machines, browser-specific issues for IE, specifically version 8, are known.
Once you are in edit mode, there are buttons in the toolbox in the left margin:
- all dates to dmy
- all dates to mdy
- body dates to dmy (ISO-style dates within ref tags are avoided)
- body dates to mdy
- Del year-in-X dates
- Expand all dates (month names within the article)
- Abbrev ref dates (only month names within the references section)
- Accessdate to YYYY-MM-DD (only access dates within the references section)
- US-slash dates
- UK-slash dates
Users are equally reminded of the following provisions of Misplaced Pages:Manual of Style (dates and numbers):
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, unless the citation style being used requires a different format (however, all-numeric date formats other than yyyy-mm-dd must still be avoided).
- Access and archive dates in references should all use the same format – either the format used for publication dates, or yyyy-mm-dd
(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
Shortcuts
- 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
- 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.
- Where an article has shown no clear sign of which format is used, the first person to insert a date is equivalent to "the first major contributor".
Test pages
- User:Full-date unlinking bot/Test environment - tests unlinking and dmy<–>mdy conversion
- User:Dl2000/testtemp7 - slash dates
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 "the 6 June beach landings". The "the" should either be reinserted, or the phrase reconfigured so that the date is no longer adjectival (e.g. "the beach landings on 6 June").
- Non-ISO-style date within citation: The 'body dates' functions will act on any non-ISO-style date within citation, so that if there is a dmy date within references (amongst dates such as 2009-01-11), the former will be acted on by the mdy function whilst the latter will be unaffected.
- wikEd: There is a conflict with wikEd that prevents the MOSNUM script from making any changes to articles. The solution is to toggle the wikEd text area off while running MOSNUM. 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. When you are done running MOSNUM 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 is no longer a conflict with wikEd. There is no need to disable/re-enable wikEd in your common.js file.
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, and seems to work as intended on the latest Firefox and Chrome browsers. However, browser-specific issues have been reported for IE on Windows machines.
By consensus, this script should not be used in articles about chronological periods, such as 2015, 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.