I have a date string coming from JSON "2012-08-01T15:42:06Z" and want to parse that in Windows Runtime. As far as I know, only COleDateTime is available to handle this.
I can only get it to correctly parse the string when I take out the 'T' & 'Z' characters, but that adds an extra parsing step on my end.
WORKS:
COleDateTime dateTime;
dateTime.ParseDateTime(L"2012-08-01 15:42:06", 0UL, 1033UL);
FAILS:
COleDateTime dateTime;
dateTime.ParseDateTime(L"2012-08-01T15:42:06Z", 0UL, 1033UL);
Anyone have any idea?
If your date string is formatted consistently, you can use
std::get_time
to parse the time into atm
struct, copy the relevant bits into aSYSTEMTIME
and from there convert to aFILETIME
and then toWindows::Foundation::DateTime
.Info on
std::get_time
: http://en.cppreference.com/w/cpp/io/manip/get_timeCode for converting from
SYSTEMTIME
toDateTime
: How do I parse a date in a Metro (C++/CX) app?