userver: userver/formats/serialize/time_of_day.hpp Source File
Loading...
Searching...
No Matches
time_of_day.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/formats/serialize/time_of_day.hpp
4/// @brief utils::datetime::TimeOfDay to any format
5/// @ingroup userver_universal userver_formats_serialize
6
7#include <fmt/format.h>
8
9#include <userver/utils/time_of_day.hpp>
10
11#include <userver/formats/serialize/to.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace formats::serialize {
16
17template <typename Value, typename Duration>
18Value Serialize(const utils::datetime::TimeOfDay<Duration>& value, To<Value>) {
19 return typename Value::Builder(fmt::to_string(value)).ExtractValue();
20}
21
22template <typename Value, typename Duration, typename StringBuilder>
23void WriteToStream(const utils::datetime::TimeOfDay<Duration>& value,
24 StringBuilder& sw) {
25 WriteToStream(fmt::to_string(value), sw);
26}
27
28} // namespace formats::serialize
29
30USERVER_NAMESPACE_END