Date Format Rule - No Numerical Month Representation

Description

This rule enforces the use of spelled-out month names in dates rather than allowing numerical representations (like MM/DD/YYYY format). The rule is based on Microsoft Style Guide recommendations and aims to improve readability and reduce confusion, particularly in international contexts where date formats can vary (e.g., DD/MM/YYYY vs MM/DD/YYYY). Using spelled-out month names eliminates ambiguity and ensures clear communication across different regions and cultures.

Examples

This rule will flag:

  • 12/25/2023
  • 1/5/2024
  • 06/30/23

Correct alternatives would be:

  • December 25, 2023
  • January 5, 2024
  • June 30, 2023

The rule works by detecting any date pattern that uses forward slashes to separate numbers in date format. It specifically looks for patterns where:

  • 1-2 digits (for day or month)
  • followed by a forward slash
  • followed by 1-2 digits (for day or month)
  • followed by a forward slash
  • followed by either 2 or 4 digits (for year)

Rule Source

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

Rule Definition

extends: existence
message: "Always spell out the name of the month."
link: https://docs.microsoft.com/en-us/style-guide/numbers#numbers-in-dates
ignorecase: true
level: error
nonword: true
tokens:
  - '\b\d{1,2}/\d{1,2}/(?:\d{4}|\d{2})\b'