-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
According to the C++ standard, month and day string parsing is meant to be case insensitive.
From https://isocpp.org/files/papers/N4860.pdf (c++ 20 draft):
or from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf (c++11 draft)
The next element of fmt is equal to’%’, optionally followed by a modifier character, followed by a conversion specifier character, format, together forming a conversion specification valid for the ISO/IEC 9945 function strptime
From https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html
Case is ignored when matching items in buf such as month or weekday names.
Clang with libc++ also parses fine: https://gcc.godbolt.org/z/ceb98o
Command-line test case
C:\Temp>type main.cpp
#include <iostream>
#include <sstream>
#include <iomanip>
int main()
{
std::tm t = {};
std::istringstream ss("2011-FEB-18");
ss >> std::get_time(&t, "%Y-%b-%d");
if (ss.fail()) {
std::cout << "Parse failed\n";
}
else {
std::cout << std::put_time(&t, "%c") << '\n';
}
}
C:\Temp>cl /EHsc /W4 /WX main.cpp
Оптимизирующий компилятор Microsoft (R) C/C++ версии 19.27.29109 для x64
(C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.
main.cpp
Microsoft (R) Incremental Linker Version 14.27.29109.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
C:\Temp>main.exe
Parse failed
Expected behavior
Expected output:
Sun Feb 18 00:00:00 2011
STL version
Microsoft Visual Studio Community 2019 Preview Version 16.7.0 Preview 6.0
Additional context
VSO-596742 / AB#596742 | DevCom-229445