#include "twitch-eventsub-ws/chrono.hpp" #include "twitch-eventsub-ws/detail/errors.hpp" #if __cpp_lib_chrono >= 201907L # include using namespace std::chrono; #else # include using namespace date; #endif namespace chatterino::eventsub::lib { boost::json::result_for::type tag_invoke(boost::json::try_value_to_tag< std::chrono::system_clock::time_point> /*tag*/, const boost::json::value &jvRoot, const AsISO8601 & /*tag*/) { const auto raw = boost::json::try_value_to(jvRoot); if (raw.has_error()) { return raw.error(); } std::chrono::time_point tp; std::istringstream in{*raw}; in >> parse("%FT%H:%M:%12SZ", tp); if (!in.good()) { EVENTSUB_BAIL_HERE(error::Kind::BadTimeFormat); } return std::chrono::time_point_cast( tp); } } // namespace chatterino::eventsub::lib