Skip to content

<xloctime>: Fix time_get::do_get format strings for %c and %x#6133

Open
BrandonPacewic wants to merge 4 commits intomicrosoft:mainfrom
BrandonPacewic:xloctime-time-get-do-get-format
Open

<xloctime>: Fix time_get::do_get format strings for %c and %x#6133
BrandonPacewic wants to merge 4 commits intomicrosoft:mainfrom
BrandonPacewic:xloctime-time-get-do-get-format

Conversation

@BrandonPacewic
Copy link
Contributor

@BrandonPacewic BrandonPacewic commented Mar 3, 2026

Fixes #6129.

time_get::do_get hardcoded the wrong format strings for %c and %x in the C locale:

  • %c was "%b %d %H : %M : %S %Y", missing the leading weekday field entirely. It should be "%a %b %e %T %Y" to match what strftime("%c") produces.
  • %x was "%d / %m / %y" (day/month order), but should be "%m/%d/%y" (month/day order) to match strftime("%x").

As the original open issue describes, this is an ABI preserving behavior change. The existing test Dev11_0836436_get_time is updated accordingly and its %x test inputs were written for the old day first format and its comment cited "%d / %m / %y" directly.

The libcxx test std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp still fails due to a separate pre-existing bug where do_get does not handle the %% specifier (falls to default: failbit) (#6130). Its entry in expected_results.txt is left in place.

Also updates P0355R7_calendars_and_time_zones_io test inputs for %c and %x, since std::chrono::parse routes those format specifiers through time_get::do_get and the existing inputs were written against the old incorrect format strings.

Force push note 🐱
I force pushed during early preparation of this PR to fix a commit message and add a missing `test.lst` entry before any review had begun. I understand that force pushing during active review is disruptive and I will not do so going forward. 🙃

@BrandonPacewic BrandonPacewic requested a review from a team as a code owner March 3, 2026 03:39
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Mar 3, 2026
@BrandonPacewic BrandonPacewic force-pushed the xloctime-time-get-do-get-format branch from 93d08fd to 3d43595 Compare March 3, 2026 03:49
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Mar 3, 2026

case 'x':
_First = _Getfmt(_First, _Last, _Iosbase, _State, _Pt, "%d / %m / %y");
_First = _Getfmt(_First, _Last, _Iosbase, _State, _Pt, "%m/%d/%y");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar specifiers, like %D and %T, continue to allow whitespace. This is consistent with the POSIX spec up to 2018, although I note that the 2024 version removes the whitespace. For consistency, I think it's better to keep it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, current implementation correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure what you're asking.

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

Labels

bug Something isn't working

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

<xloctime>: time_get::do_get uses the wrong format for %c and %x

4 participants