-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The C++ standard time_put defers to strftime, 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
C:\Users\bion\Desktop>type repro.cpp
#include <iostream>
#include <locale>
using namespace std;
class ctst : public std::time_put<char>{};
int main() {
ctst stdtp;
struct tm _tm {
0, 0, 23, 1, 0, 0, 0, 0, 0
};
char format[]{'%', 'r', 0};
stdtp.put(cout, cout, cout.fill(), &_tm, &format[0], &format[2]);
cout << '\n';
stdtp.put(cout, cout, cout.fill(), &_tm, format[1]);
cout << '\n';
return 0;
}
C:\Users\bion\Desktop>cl /EHsc .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
Microsoft (R) Incremental Linker Version 14.24.28314.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repro.exe
repro.obj
C:\Users\bion\Desktop>.\repro.exe
23:00:00
23:00:00
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.
Line 729 in aa0a7a3
| if (0 < (_Count = _Strftime(&_Str[0], _Str.size(), _Fmt, _Pt, _Tnames._Getptr()))) { |
This item is also tracked on Developer Community as DevCom-758960 and by Microsoft-internal VSO-998596 / AB#998596.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working