userver: /data/code/userver/libraries/protobuf/include/userver/protobuf/datetime.hpp Source File
Loading...
Searching...
No Matches
datetime.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5/// @file userver/protobuf/datetime.hpp
6/// @brief Date and time protobuf utilities.
7
8USERVER_NAMESPACE_BEGIN
9
10namespace protobuf {
11
12constexpr inline std::int64_t kMinDurationSeconds = -315'576'000'000LL;
13constexpr inline std::int64_t kMaxDurationSeconds = 315'576'000'000LL;
14constexpr inline std::int32_t kMinDurationNanos = -999'999'999;
15constexpr inline std::int32_t kMaxDurationNanos = 999'999'999;
16constexpr inline std::int64_t kMinTimestampSeconds = -62'135'596'800LL;
17constexpr inline std::int64_t kMaxTimestampSeconds = 253'402'300'799LL;
18constexpr inline std::int32_t kMinTimestampNanos = 0;
19constexpr inline std::int32_t kMaxTimestampNanos = 999'999'999;
20
21/// @brief Returns @c true if combination of @a seconds and @a nanos represent a valid `google.protobuf.Duration`.
22[[nodiscard]] bool IsValidDuration(std::int64_t seconds, std::int32_t nanos) noexcept;
23
24/// @brief Returns @c true if combination of @a seconds and @a nanos represent a valid `google.protobuf.Timestamp`.
25[[nodiscard]] bool IsValidTimestamp(std::int64_t seconds, std::int32_t nanos) noexcept;
26
27} // namespace protobuf
28
29USERVER_NAMESPACE_END