Time Range Format Rule

Description

This rule enforces consistent formatting of time ranges by requiring the use of the word "to" instead of dashes or en dashes between AM/PM times. This aligns with Microsoft's style guide recommendations for time ranges. Using consistent formatting for time ranges improves readability and maintains professional standards across documentation.

Examples

This rule will flag:

  • "9AM-5PM" → Should be "9AM to 5PM"
  • "10:30 AM – 2:00 PM" → Should be "10:30 AM to 2:00 PM"
  • "8PM-11PM" → Should be "8PM to 11PM"

The rule specifically looks for:

  • Time ranges where times include AM/PM indicators
  • Ranges connected by either a hyphen (-) or en dash (–)
  • Will automatically suggest replacing the dash with "to"

The rule will not flag time ranges that:

  • Don't include AM/PM indicators
  • Already use "to" instead of dashes
  • Use other time formats

Rule Source

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

Rule Definition

extends: existence
message: "Use 'to' instead of a dash in '%s'."
link: https://docs.microsoft.com/en-us/style-guide/numbers
nonword: true
level: error
action:
  name: edit
  params:
    - replace
    - '[-–]'
    - 'to'
tokens:
  - '\b(?:AM|PM)\s?[-–]\s?.+(?:AM|PM)\b'