-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<locale>: time_put.put("%r") prints a 24-hour time rather than a 12-hour time #371
Comments
I checked the UCRT library on my machine from C:\Program Files (x86)\Windows Kits\10\Source\10.0.18362.0 and the function that gets eventually called to expand the %r processing (expand_time) has a comment that states:
So I'm assuming that the reason for the 24 hour time is that when it's not in the C locale it uses the WW_TIMEFORMAT, which on your machine drops you at a 24 hour time format. If it's verifyable that you're on C standard locale when you're testing this and you're still getting 24 hour time I'd be very confused since expand_time calls itself recursively for the values of: %I:%M:%S %p as given in the comments, meaning that expand_time failing for doing 12 hour time here would be the fault of %I, which mods the current time by 12 before printing it in the first place, making it impossible for %I to be the failure point. TL;DR because I know I'm rambling: Check if you're on the C standard locale for this, but AFAICT the issue at hand is that the system deferring to local locale is causing the issue and that adding a forced 12-hour local locale for all locales will be the solution here, because the C standard locale is fine. |
@chuggafan In the original repro the locale has not been changed, so it should be in the default (that is, "C") locale setting. The bug is that we are apparently not propagating that to all the right places correctly. |
I took a look at this, and it appears to be a UCRT issue. STL calls |
Describe the bug
The C++ standard
time_put
defers tostrftime
, and the C standard says that%r
is intended to print a 12-hour time. However, we appear to be printing a 24-hour time.Command-line test case
Expected behavior
The output should have been a 12-hour time rather than a 24-hour time.
Additional context
It looks like we get the CRT rather than the STL to do most of this processing, so the result may be reducing this to a UCRT test case and submitting that against Windows.
STL/stl/inc/xloctime
Line 729 in aa0a7a3
This item is also tracked on Developer Community as DevCom-758960 and by Microsoft-internal VSO-998596 / AB#998596.
The text was updated successfully, but these errors were encountered: