Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 246
doctorlove Avatar asked Jun 07 '13 09:06

doctorlove


1 Answers

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

like image 140
doctorlove Avatar answered Nov 10 '22 19:11

doctorlove