HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.14k stars 675 forks source link

How to parse datetime with milliseconds and timezone? #825

Open StasLina opened 5 months ago

StasLina commented 5 months ago

I'm trying to convert the date and time with the time zone and milliseconds, but it doesn't work. How can this be done correctly? Without milliseconds it works, but me need milliseconds too.

    std::istringstream in{ "2024-04-30T10:31:38.326+03:00" };
    sys_seconds tp;
    in >> date::parse("%FT%T%Ez", tp);
HowardHinnant commented 5 months ago

Change:

sys_seconds tp;

to:

sys_time<milliseconds> tp;

(adding namespace qualifiers if necessary)