Date Format Validator

Description

This rule enforces consistent date formatting by requiring dates to be written in the format "Month DD, YYYY" (e.g., "July 31, 2016") rather than "DD Month YYYY" format. This aligns with Microsoft's style guide recommendations for date formatting. Consistent date formatting is crucial for clarity and professionalism in documentation, helping avoid confusion, particularly in international contexts where date formats can vary significantly.

Examples

This rule will flag dates in the following format:

  • ❌ 31 July 2016
  • ❌ 15 Jan 2023
  • ❌ 1 December 2020

And expects them to be written as:

  • ✅ July 31, 2016
  • ✅ January 15, 2023
  • ✅ December 1, 2020

The rule is case-insensitive and works with both full month names and their abbreviated forms (Jan, Feb, etc.). It specifically looks for patterns where the day comes before the month, which is common in European date formatting but not preferred in Microsoft's style guide.

Rule Source

This rule comes from: https://github.com/mesosphere/dcos-docs-site

Rule Definition

extends: existence
message: Use 'July 31, 2016' format, not '%s'.
link: https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/date-time-terms
ignorecase: true
level: error
nonword: true
tokens:
  - '\d{1,2} (?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)|May|Jun(?:e)|Jul(?:y)|Aug(?:ust)|Sep(?:tember)?|Oct(?:ober)|Nov(?:ember)?|Dec(?:ember)?) \d{4}'