jelmew
jelmew

Reputation: 583

get_time not operating as expected

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

Answers (1)

Tyker
Tyker

Reputation: 3047

in the link OP gave it is clearly said

Example

note: choose clang to observe the output. libstdc++ does not correctly implement the %b specifier: bug 78714

Upvotes: 3

Related Questions