Reputation: 583
I was playing around with the put_time
and get_time
functions and I ran into some problems.
I took this code:
#include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>
int main()
{
std::tm t = {};
std::istringstream ss("2011-Februar-18 23:12:34");
ss.imbue(std::locale("de_DE.utf-8"));
ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S");
if (ss.fail()) {
std::cout << "Parse failed\n";
} else {
std::cout << std::put_time(&t, "%c") << '\n';
}
}
From here. However, when compiling with both gcc version 8.8.1 and clang version 6.0.0 I get parse failed, even though the exacmple at cppreference should work with clang.
Anyone who could enlighten me what goes wrong?
Upvotes: 4
Views: 399