I need to parse a timestamp with timezone into a c++ timepoint.
My environment is linux and gcc 14.1 and -std=c++23.
My definitions are:
namespace MyTime {
using clock_t = std::chrono::system_clock;
using duration_t = clock_t::duration;
using time_point_t = std::chrono::zoned_time<duration_t>;
time_point_t now()
{
return std::chrono::zoned_time{std::chrono::current_zone(), clock_t::now()};
}
std::string to_string(time_point_t tp)
{
std::ostringstream oss;
oss << std::format("{0:%Y-%m-%dT%T%Z}", tp);
return oss.str();
}
time_point_t from_string(std::string_view str)
{
std::istringstream iss{std::string(str)};
time_point_t tp{};
iss >> std::chrono::parse("%Y-%m-%dT%T%Z",tp);
return std::chrono::time_point {tp};
}
}
MyTime::from_string(std::string_view str) gives me a compilation error.
How to compile this successfully?