https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71557
Bug ID: 71557
Summary: time_get is case sensitive
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Howard writes:
Consider:
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
int main() {
tm tmbuf;
stringstream str("20:48:01 MAR 31 2016");
str >> get_time(&tmbuf, "%H:%M:%S %b %d %Y");
cout << put_time(&tmbuf, "%m-%d-%Y") << endl;
}
The expected output is:
03-31-2016
The issue is “MAR”. If I change to “Mar” then everyone gets the right answer.
Now to argue the case for “MAR”:
[locale.time.get.members]/p12, in describing the effects of do_get,
references ISO/IEC 9945 strptime for the format characters such as
“%b”. Here’s a link to that specification:
http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
> Case is ignored when matching items in buf such as month or weekday names.
c.f. http://stackoverflow.com/q/37856887/576911