doctorlove
doctorlove

Reputation: 19262

Debug assert "Invalid format directive" for std::put_time

I'm learning to use C++11 chrono, and am trying to output the time. Other SO questions show some code samples, e.g.

std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now - std::chrono::hours(24));
std::cout  << std::put_time(std::localtime(&now_c), "%F %T") << '\n';

When I run this on VS2012 in debug, I get a debug assert claiming I've used an "Invalid format directive".

The same happens if I use std::strftime. I presume the %F and %T are not supported by Microsoft?

Upvotes: 11

Views: 2779

Answers (1)

doctorlove
doctorlove

Reputation: 19262

It is purely because %F and %T are not supported by Microsoft.

Upvotes: 17

Related Questions