Is a delimiter required for parsing a string using std :: get_time? I can not find the link to say that it is. I am trying to parse an ISO date and time string such as "20140105T123456" - for example:
For instance,
#include <iostream> #include <sstream> #include <locale> #include <iomanip> #include <ctime> int main(int argc, char* argv[]) { std::tm t = { 0 }; // fails std::istringstream ss("20141105T123456"); ss >> std::get_time(&t, "%Y%m%dT%H%M%S"); // works //std::istringstream ss("2014 11 05 T 12 34 56"); //ss >> std::get_time(&t, "%Y %m %d T %H %M %S"); std::ostringstream os; std::cout << std::put_time(&t, "%c") << std::endl; }
I am using Visual Studio 2013. I tried to use Linux, but I have the latest version of GCC 4.7.3, which does not yet support get_time.
Is there a deep mistake on my part or do you need separators?
source share