I'm trying to parse a date formatted as YYMMDD
. As a test, I've tried the following code:
#include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>
int main(){
std::tm t = {};
std::istringstream ss("191203");
ss >> std::get_time(&t, "%y%m%d");
if (ss.fail()){
std::cout << "Parse failed\n";
} else {
std::cout << std::put_time(&t, "%c") << '\n';
}
}
Tested with Coliru, GCC 6.1 (C++17), the output is:
Sun Mar 0 00:00:00 1912
What I expected is:
Mon Dec 3 00:00:00 2019
Is there something wrong in the format string?