vendredi 22 juin 2018

C++ 11 - Parsing of the following date string "2009-01-01T00:00:00.000Z"

I'm using simple method for parsing incoming date strings into "date::sys_seconds" objects:

template<typename StringT, typename ResolutionT = date::sys_seconds>
    date::sys_seconds DateTimeToVal(const StringT& s, const StringT& format)
    {
        std::basic_istringstream<typename StringT::value_type> in{ s };
        ResolutionT tp;
        in >> date::parse(format, tp);

        return tp;
    }

If the date is as follows: "2009-01-01T00:00:00.000" and I use the following format: "L"%Y-%m-%dT%H:%M:%S" than it works as expected.

But I need to parse date string in the following format: "2009-01-01T00:00:00.000Z" (there is additional "Z" at the end identifying time zone).

Adding additional "Z" at the end of format : "L"%Y-%m-%dT%H:%M:%SZ" doesn't seem to work.

Thanks a lot.

Aucun commentaire:

Enregistrer un commentaire