diff --git a/lib/l10n-en_GB.js b/lib/l10n-en_GB.js index 00ffc670e..6f3d49ed1 100644 --- a/lib/l10n-en_GB.js +++ b/lib/l10n-en_GB.js @@ -16,9 +16,9 @@ export const messages = { 'Duplicate <hr> at the end of, and right after, div.head.', // headers/w3c-state 'headers.w3c-state.no-w3c-state': - 'Cannot find the <p id="w3c-state"> element for profile and date.

Please make sure the <p id="w3c-state">W3C @@Profile, DD Month Year</p> element can be selected by document.getElementById("w3c-state");
If you are using bikeshed, please update to the latest version.', + 'Cannot find the <p id="w3c-state"> element for profile and date.

Please make sure the <p id="w3c-state">W3C @@Profile, DD Month YYYY</p> element can be selected by document.getElementById("w3c-state");
If you are using bikeshed, please update to the latest version.', 'headers.w3c-state.bad-w3c-state': - 'Incorrect w3c status element, <p id="w3c-state">. <p id="w3c-state">W3C @@Profile, DD Month Year</p>.', + 'Incorrect w3c status element, <p id="w3c-state">. <p id="w3c-state">W3C @@Profile, DD Month YYYY</p>.', 'headers.w3c-state.no-w3c-state-link': 'Cannot find the link of the W3C profile in id="w3c-state" element pointing to "https://www.w3.org/standards/types#xx".', 'headers.w3c-state.wrong-w3c-state-link': diff --git a/lib/rules.json b/lib/rules.json index 1d4c5fcc8..693c1ea83 100644 --- a/lib/rules.json +++ b/lib/rules.json @@ -1603,7 +1603,7 @@ "rules": { "sotd": "There must be a status section that follows the abstract, labeled with an h2 element with content \"Status of This Document\". The Team maintains the status section of a document.", "boilerplateTRDoc": "It must begin with the following boilerplate text:

This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

Include this source code:
<p><em>This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the <a href=\"https://www.w3.org/TR/\">W3C technical reports index</a> at https://www.w3.org/TR/.</em></p>
", - "datesFormat": "All dates must have the form DD Month YYYY. A leading zero in the day is optional.", + "datesFormat": "All dates must have one of the following forms:
  1. DD Month YYYY : 09 January 2020
  2. DD-Month-YYYY : 09-January-2020
  3. DD Mon YYYY : 09 Jan 2020
  4. DD-Mon-YYYY : 09-Jan-2020
A leading zero in the day is optional.", "publish": "It must include the name of the W3C group that produced the document, the type of document and its track. The name must be a link to a public page for the group.

This document was published by the @@@ Working/Interest Group as a @{param1} using the @{param2}.

Include this source code:
<p>This document was published by the <a href=\"https://www.w3.org/groups/(wg|ig)/@@\">@@@ Working/Interest Group</a> as a @{param1} using the @{param3}.</p>
", "customParagraph": "It must include at least one customized paragraph. This section should include the title page date (i.e., the one next to the maturity level at the top of the document). These paragraphs should explain the publication context, including rationale and relationships to other work. See examples and more discussion in the Manual of Style.", "changesList": "It @{param1} include a link to changes since the previous draft (e.g., a list of changes or a diff document or both; see the online HTML diff tool).@{param2}", @@ -1656,7 +1656,7 @@ "rec-edit-w3c-state": { "name": "3. Change the title of the document", "rules": { - "w3c-state": "In the <p id=\"w3c-state\"> element containing the state and date (\"W3C Recommendation DD MMMMMM YYYY\"), add:
  1. a <br> element after the original date
  2. and \"@{param1} <new date>\" when the @{param1} document gets published by the webmaster
" + "w3c-state": "In the <p id=\"w3c-state\"> element containing the state and date (\"W3C Recommendation DD Month YYYY\"), add:
  1. a <br> element after the original date
  2. and \"@{param1} <new date>\" when the @{param1} document gets published by the webmaster
" } }, "rec-edit-version": { diff --git a/lib/rules/heuristic/date-format.js b/lib/rules/heuristic/date-format.js index 8363d95f1..93484959d 100644 --- a/lib/rules/heuristic/date-format.js +++ b/lib/rules/heuristic/date-format.js @@ -1,3 +1,5 @@ +import { possibleMonths } from '../../validator.js'; + const self = { name: 'heuristic.date-format', section: 'document-status', @@ -12,14 +14,12 @@ export const { name } = self; */ export function check(sr, done) { // Pseudo-constants: - const MONTHS = - 'jan|january|feb|february|mar|march|apr|april|may|jun|june|jul|july|aug|august|sep|september|oct|october|nov|november|dec|december'; const POSSIBLE_DATE = new RegExp( - `\\b([0123]?\\d|${MONTHS})[\\ \\-\\/–—]([0123]?\\d|${MONTHS})[\\ \\-\\/–—]([\\'‘’]?\\d{2})(\\d\\d)?\\b`, + `\\b([0123]?\\d|${possibleMonths})[\\ \\-\\/–—]([0123]?\\d|${possibleMonths})[\\ \\-\\/–—]([\\'‘’]?\\d{2})(\\d\\d)?\\b`, 'gi' ); const EXPECTED_DATE_FORMAT = new RegExp( - `[0123]?\\d\\ (${MONTHS})\\ \\d{4}`, + `[0123]?\\d\\ (${possibleMonths})\\ \\d{4}`, 'i' ); diff --git a/lib/validator.js b/lib/validator.js index 17c147e0b..801f922a5 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -266,16 +266,41 @@ Specberus.prototype.norm = function (str) { return str.replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' '); }; -const months = - 'January February March April May June July August September October November December'.split( - ' ' - ); -Specberus.prototype.dateRegexStrCapturing = `(\\d?\\d) (${months.join( - '|' -)}) (\\d{4})`; -Specberus.prototype.dateRegexStrNonCapturing = `\\d?\\d (?:${months.join( - '|' -)}) \\d{4}`; +const months = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', +]; +const abbrMonths = [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'May', + 'Jun', + 'Jul', + 'Aug', + 'Sep', + 'Oct', + 'Nov', + 'Dec', +]; + +export const possibleMonths = [...months, ...abbrMonths].join('|'); + +const separator = '[ -]{1}'; + +Specberus.prototype.dateRegexStrCapturing = `(\\d?\\d)${separator}(${possibleMonths})${separator}(\\d{4})`; +Specberus.prototype.dateRegexStrNonCapturing = `\\d?\\d${separator}(?:${possibleMonths})${separator}\\d{4}`; Specberus.prototype.stringToDate = function (str) { const rex = new RegExp(this.dateRegexStrCapturing); diff --git a/test/rules.js b/test/rules.js index 186e93e75..42dc922a1 100644 --- a/test/rules.js +++ b/test/rules.js @@ -332,7 +332,7 @@ function buildHandler(test, mock, done) { 'https://www.w3.org/Consortium/Patent-Policy-20170801/', }, { - end: '2024-09-30', + end: '2090-09-30', 'doc-licenses': [ { uri: 'https://www.w3.org/Consortium/Legal/copyright-software', @@ -350,7 +350,7 @@ function buildHandler(test, mock, done) { start: '2010-05-17', }, 83907: { - end: '2023-07-31', + end: '2090-07-31', 'doc-licenses': [ { uri: 'https://www.w3.org/Consortium/Legal/copyright-documents', @@ -366,7 +366,7 @@ function buildHandler(test, mock, done) { 'https://www.w3.org/Consortium/Patent-Policy-20200915/', }, 35422: { - end: '2022-10-31', + end: '2090-10-31', 'doc-licenses': [ { uri: 'https://www.w3.org/Consortium/Legal/copyright-documents',