Skip to content

Remove the '0' chrono padding modifier from the docs - #4917

Merged
vitaut merged 1 commit into
fmtlib:mainfrom
dylanpulver:docs-drop-removed-zero-padding-modifier
Sep 5, 2026
Merged

Remove the '0' chrono padding modifier from the docs#4917
vitaut merged 1 commit into
fmtlib:mainfrom
dylanpulver:docs-drop-removed-zero-padding-modifier

Conversation

@dylanpulver

Copy link
Copy Markdown
Contributor

doc/syntax.md documents a chrono padding modifier that the parser rejects.

The grammar says padding_modifier ::= "-" | "_" | "0" and the table below it
lists a '0' row, for the 11 presentation types the same section names
(H I M S U V W Y d j m). But parse_chrono_format only has cases for '_'
and '-', so every %0 spelling throws format_error: invalid format.

Measured on main (bc82c40), all 11 documented types, std::tm and
std::chrono::seconds, 44 cells:

modifier OK error
(none) 11 0
- 11 0
_ 11 0
0 0 11
fmt::format("{:%H}",  tm);  // "03"
fmt::format("{:%-H}", tm);  // "3"
fmt::format("{:%_H}", tm);  // " 3"
fmt::format("{:%0H}", tm);  // throws: invalid format

The docs are the stale side, not the code. ca8eeb09 (#3976, 2024-05-30)
added the '0' grammar and table row; 7bd11b5c (2024-06-08, nine days
later) removed case '0' and its tests under "Remove a redundant extension
to reduce divergence from std::format"
, touching only chrono.h and
chrono-test.cc. Zero padding is the default, so it was redundant — this
just drops the two stale mentions and notes the default.

Docs-only. The "only supported for" list is accurate: all 11 do honor -
and _, checked with values short enough to discriminate.

Drafted with Claude Code (claude-opus-5); measurements and archaeology run
and reviewed by me.

The '0' modifier was documented in ca8eeb0 (fmtlib#3976) and the parser case for
it was removed nine days later in 7bd11b5 ("Remove a redundant extension to
reduce divergence from std::format"), which did not update the docs. Since
then the grammar and the modifier table have promised a modifier that
parse_chrono_format rejects with "invalid format", for all 11 of the
presentation types the same section lists as supporting it.

Zero padding remains the default, so the extension really was redundant;
this only aligns the documentation with the code.

Co-authored-by: Claude <noreply@anthropic.com>
@vitaut
vitaut merged commit a389757 into fmtlib:main Sep 5, 2026
47 checks passed
@vitaut

vitaut commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants