9#include <userver/storages/postgres/exceptions.hpp>
10#include <userver/storages/postgres/io/buffer_io.hpp>
11#include <userver/storages/postgres/io/buffer_io_base.hpp>
12#include <userver/storages/postgres/io/integral_types.hpp>
13#include <userver/storages/postgres/io/traits.hpp>
14#include <userver/storages/postgres/io/type_mapping.hpp>
16USERVER_NAMESPACE_BEGIN
24 using DurationType = std::chrono::microseconds;
28 Bigint microseconds = 0;
30 constexpr Interval() =
default;
31 constexpr Interval(Integer months, Integer days, Bigint microseconds)
32 : months{months}, days{days}, microseconds{microseconds} {}
33 constexpr explicit Interval(DurationType ms) : microseconds{ms.count()} {}
35 constexpr bool operator==(
const Interval& rhs)
const {
36 return months == rhs.months && days == rhs.days &&
37 microseconds == rhs.microseconds;
39 constexpr bool operator!=(
const Interval& rhs)
const {
40 return !(*
this == rhs);
43 constexpr DurationType GetDuration()
const {
45 return std::chrono::duration_cast<DurationType>(
46 std::chrono::microseconds{microseconds} +
47 std::chrono::hours{days * 24});
96struct CppToSystemPg<detail::Interval>
97 : PredefinedOid<PredefinedOids::kInterval> {};