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 && microseconds == rhs.microseconds;
38 constexpr bool operator!=(
const Interval& rhs)
const {
return !(*
this == rhs); }
40 constexpr DurationType GetDuration()
const {
42 return std::chrono::duration_cast<DurationType>(
43 std::chrono::microseconds{microseconds} + std::chrono::hours{days * 24}
85struct CppToSystemPg<detail::Interval> : PredefinedOid<PredefinedOids::kInterval> {};