userver: /data/code/userver/libraries/proto-structs/src/proto-structs/timestamp.cpp Source File
Loading...
Searching...
No Matches
timestamp.cpp
1#include <userver/proto-structs/timestamp.hpp>
2
3#include <fmt/chrono.h>
4#include <fmt/format.h>
5
6#include <userver/proto-structs/exceptions.hpp>
7#include <userver/utils/impl/internal_tag.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace proto_structs {
12
13Timestamp::Timestamp(utils::impl::InternalTag, std::int64_t seconds, std::int32_t nanos)
14 : Timestamp(std::chrono::seconds{seconds}, std::chrono::nanoseconds{nanos}) {}
15
16void Timestamp::ThrowError(const std::chrono::seconds& seconds, const std::chrono::nanoseconds& nanos) {
17 throw ValueError(fmt::format("Timestamp '{}s.{}ns' is invalid or out of range", seconds.count(), nanos.count()));
18}
19
20void Timestamp::ThrowError(const char* reason) { throw ValueError(reason); }
21
22} // namespace proto_structs
23
24USERVER_NAMESPACE_END