Date Range with endash should exclude spaces

Created on 7 July 2025, 29 days ago

Problem/Motivation

We use this module, but we had to remove the spaces around the endash by editing src/ApStyleDateFormatter.php in version 1.9, and I still see the latest version includes these spaces. Everything I read claims there are no spaces when using the endash in a date/time range.

Ranges with the endash should appear as:

  • July 24, 2025, 3–5 p.m.
  • July 24–25, 2025

not:

  • July 24, 2025, 3 – 5 p.m.
  • July 24 – 25, 2025

Proposed resolution

I included a patch against the latest code from GitHub which demonstrates the fix for this issue, since we have to do this for our production environment.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @bjared
  • First commit to issue fork.
  • 🇺🇸United States shelane

    This must come from a rule other than AP style. In fact, using an ndash is not even part of the AP style standard, but I believe that it was included at user request as an option. Can you provide any sources on why spaces should not be included?

  • Hi, shelane.

    I found a couple of references.

    The AP Stylebook (n.d.) uses time examples such as, "Use figures except for noon and midnight. Use a colon to separate hours from minutes: 11 a.m., 1 p.m., 3:30 p.m., 9-11 a.m., 9 a.m. to 5 p.m." which includes an hyphen, but as you said, there doesn't seem to be a rule specific about en dashes, but you can see they omitted spaces around it.

    Alexander (2024) writes, "There should be no space surrounding a hyphen (ex: Jan. 1-4)" (p. 2).

    Emmitt (2021) also mentions the usage of a hyphen instead of an en dash stating, "AP style advises the use of a hyphen in place of an en dash, as a slash may not be transcribed correctly in some systems", and follows that statement with three examples that exclude spaces around the hyphen. Just below that section Emmitt states that Chicago style prefers the en dash.

    So, I suppose I'd argue that if we keep the en dash (instead of a hyphen), we should at least omit the surrounding spaces. I personally like the en dash, and that's a specific requirement mentioned in my organization's style guide, which makes me now wonder if they've based their guidelines on the Chicago style or the AP style...

    Anyway, thank you for entertaining this issue with me. I will leave this in your capable hands. I didn't expect this to be such a peculiar situation, so if we must, we are comfortable adding a patch into our composer.json to tweak it for our needs. It's a very useful module, so thank you for the work you've done on it!

    --Brian

    References

    Alexander, V. (2024). AP style. San José State University Writing Center. https://www.sjsu.edu/writingcenter/docs/handouts/AP%20Style-2024.pdf

    AP Stylebook. (n.d.). Ask the editor: Highlights. https://apstylebook.com/ask_the_editors/style_guidance

    Emmitt, D. (2021, May 21). How to write number ranges (a complete guide). https://www.debbie-emmitt.com/how-to-write-number-ranges-a-complete-guid...

Production build 0.71.5 2024