I am trying to read/write dates in this format: yyyy-mm-ddThh:mm:ssZ
I'm doing this :
boost::posix_time::ptime t = boost::posix_time::time_from_string( "2012-02-20T00:26:39Z" );
std::cout << boost::posix_time::to_iso_extended_string( t ) << std::endl;
it works if I remove the final Z, but if I keep it an exception is thrown (bad lexical cast: source type value could not be interpreted as target).
Is there a better way to handle those dates, without manually removing/adding the Z? From what I read here and there, I understand the Z means GMT and if it's not present it means the time is in the local time zone. I'd like some generic and bugfree version to read it.