8#include <userver/utils/time_of_day.hpp>
10#include <userver/formats/common/meta.hpp>
11#include <userver/formats/parse/to.hpp>
13USERVER_NAMESPACE_BEGIN
15namespace formats::
parse {
17template <
typename Value,
typename Duration>
18std::enable_if_t<common::kIsFormatValue<Value>,
19 utils::datetime::TimeOfDay<Duration>>
20Parse(
const Value& value, To<utils::datetime::TimeOfDay<Duration>>) {
21 std::optional<std::string> str;
23 str = value.
template As<std::string>();
24 return utils::datetime::TimeOfDay<Duration>{*str};
25 }
catch (
const std::exception& e) {
27 throw typename Value::ParseException(
28 "'" + *str +
"' cannot be parsed to `utils::datetime::TimeOfDay`");
30 throw typename Value::ParseException(
31 "Only strings can be parsed as `utils::datetime::TimeOfDay`");