userver: proto_structs::TimeOfDay Class Reference
Loading...
Searching...
No Matches
proto_structs::TimeOfDay Class Reference

#include </data/code/userver/libraries/proto-structs/include/userver/proto-structs/time_of_day.hpp>

Detailed Description

Type to represent google.type.TimeOfDay in proto structs.

This type is organized in the same way as its protobuf counterpart and allows for the same range of values described here https://github.com/googleapis/googleapis/blob/master/google/type/timeofday.proto : from 00:00:00.0 to 24:00:00.0 inclusive, with leap seconds support (represented as value 60 for seconds).

Definition at line 42 of file time_of_day.hpp.

Public Types

using ProtobufMessage = ::google::type::TimeOfDay
 

Public Member Functions

constexpr TimeOfDay ()=default
 Creates 00:00:00.0 time of the day.
 
constexpr TimeOfDay (const std::chrono::hours &hours, const std::chrono::minutes &minutes, const std::chrono::seconds &seconds, const std::chrono::nanoseconds &nanos=std::chrono::nanoseconds{0})
 Creates time of the day from components.
 
template<typename TRep, typename TPeriod>
constexpr TimeOfDay (const std::chrono::hh_mm_ss< std::chrono::duration< TRep, TPeriod > > &hms)
 Creates time of the day.
 
template<typename TRep, typename TPeriod>
constexpr TimeOfDay (const utils::datetime::TimeOfDay< std::chrono::duration< TRep, TPeriod > > &time_of_day) noexcept
 Creates time of the day.
 
template<typename TRep, typename TPeriod>
constexpr TimeOfDay (std::chrono::duration< TRep, TPeriod > duration)
 Creates time of the day from the duration.
 
constexpr TimeOfDay (const std::chrono::system_clock::time_point &time_point) noexcept
 Creates time of the day evaluating it since the midnight before time_point.
 
 TimeOfDay (utils::impl::InternalTag, std::int32_t hours, std::int32_t minutes, std::int32_t seconds, std::int32_t nanos)
 
constexpr const std::chrono::hours & Hours () const noexcept
 Returns hours (from 0 to 24).
 
constexpr const std::chrono::minutes & Minutes () const noexcept
 Returns minutes (from 0 to 59).
 
constexpr const std::chrono::seconds & Seconds () const noexcept
 Returns seconds (from 0 to 59 in most cases, however 60 is also valid to support APIs with leap-seconds support).
 
constexpr const std::chrono::nanoseconds & Nanos () const noexcept
 Returns nanoseconds (from 0 to 999'999'999).
 
template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr std::chrono::hh_mm_ss< TDuration > ToChronoTimeOfDay () const noexcept
 Converts time of the day to std::chrono::hh_mm_ss.
 
template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr TDuration ToChronoDuration () const noexcept
 Converts time of the day to std::chrono::duration.
 
template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr utils::datetime::TimeOfDay< TDuration > ToUserverTimeOfDay () const noexcept
 Converts time of the day to userver::utils::datetime::TimeOfDay.
 
constexpr Duration ToUserverDuration () const noexcept
 Converts time of the day to userver::proto_structs::Duration.
 
template<typename TTimeOfDay>
requires ::meta::kIsInstantiationOf< std::chrono::hh_mm_ss, TTimeOfDay > constexpr operator TTimeOfDay () const noexcept
 Explicit conversion to std::chrono::hh_mm_ss.
 
template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr operator TDuration () const noexcept
 Explicit conversion to std::chrono::duration.
 
template<typename TTimeOfDay>
requires ::meta::kIsInstantiationOf< utils::datetime::TimeOfDay, TTimeOfDay > constexpr operator TTimeOfDay () const noexcept
 Explicit conversion to userver::utils::datetime::TimeOfDay.
 
constexpr operator Duration () const noexcept
 Explicit conversion to userver::proto_structs::Duration.
 
auto operator<=> (const TimeOfDay &) const =default
 Default three-way comparison operator.
 

Static Public Member Functions

template<typename TRep, typename TPeriod>
static constexpr bool IsValid (const std::chrono::hours &hours, const std::chrono::minutes &minutes, const std::chrono::seconds &seconds, const std::chrono::duration< TRep, TPeriod > &subseconds) noexcept
 Returns true if all components represent a valid google.type.TimeOfDay value.
 

Member Typedef Documentation

◆ ProtobufMessage

using proto_structs::TimeOfDay::ProtobufMessage = ::google::type::TimeOfDay

Definition at line 44 of file time_of_day.hpp.

Constructor & Destructor Documentation

◆ TimeOfDay() [1/5]

proto_structs::TimeOfDay::TimeOfDay ( const std::chrono::hours & hours,
const std::chrono::minutes & minutes,
const std::chrono::seconds & seconds,
const std::chrono::nanoseconds & nanos = std::chrono::nanoseconds{0} )
inlineconstexpr

Creates time of the day from components.

Exceptions
ValueErrorif some component is outside the allowed range:
  • [0, 24] for hours (24 is valid only if all other components are zeros)
  • [0, 59] for minutes
  • [0, 60] for seconds (60 may be used by APIs which need leap seconds)
  • [0, 999'999'999] for nanos

Definition at line 55 of file time_of_day.hpp.

◆ TimeOfDay() [2/5]

template<typename TRep, typename TPeriod>
proto_structs::TimeOfDay::TimeOfDay ( const std::chrono::hh_mm_ss< std::chrono::duration< TRep, TPeriod > > & hms)
inlineconstexpr

Creates time of the day.

Exceptions
ValueErrorif hms is outside the allowed range.
Note
This constructor does not check whether hms contains a leap second to represent it accordingly (i.e. with seconds part equal 60). Use overload which explicitly accepts components of the time of the day.

Definition at line 72 of file time_of_day.hpp.

◆ TimeOfDay() [3/5]

template<typename TRep, typename TPeriod>
proto_structs::TimeOfDay::TimeOfDay ( const utils::datetime::TimeOfDay< std::chrono::duration< TRep, TPeriod > > & time_of_day)
inlineconstexprnoexcept

Creates time of the day.

Definition at line 86 of file time_of_day.hpp.

◆ TimeOfDay() [4/5]

template<typename TRep, typename TPeriod>
proto_structs::TimeOfDay::TimeOfDay ( std::chrono::duration< TRep, TPeriod > duration)
inlineexplicitconstexpr

Creates time of the day from the duration.

Exceptions
ValueErrorif duration is out of range.

Definition at line 98 of file time_of_day.hpp.

◆ TimeOfDay() [5/5]

proto_structs::TimeOfDay::TimeOfDay ( const std::chrono::system_clock::time_point & time_point)
inlineexplicitconstexprnoexcept

Creates time of the day evaluating it since the midnight before time_point.

Definition at line 116 of file time_of_day.hpp.

Member Function Documentation

◆ Hours()

const std::chrono::hours & proto_structs::TimeOfDay::Hours ( ) const
inlinenodiscardconstexprnoexcept

Returns hours (from 0 to 24).

Special value 24 may be use in scenarios like business closing time.

Definition at line 130 of file time_of_day.hpp.

◆ IsValid()

template<typename TRep, typename TPeriod>
static constexpr bool proto_structs::TimeOfDay::IsValid ( const std::chrono::hours & hours,
const std::chrono::minutes & minutes,
const std::chrono::seconds & seconds,
const std::chrono::duration< TRep, TPeriod > & subseconds )
inlinestaticnodiscardconstexprnoexcept

Returns true if all components represent a valid google.type.TimeOfDay value.

Definition at line 199 of file time_of_day.hpp.

◆ Minutes()

const std::chrono::minutes & proto_structs::TimeOfDay::Minutes ( ) const
inlinenodiscardconstexprnoexcept

Returns minutes (from 0 to 59).

Definition at line 133 of file time_of_day.hpp.

◆ Nanos()

const std::chrono::nanoseconds & proto_structs::TimeOfDay::Nanos ( ) const
inlinenodiscardconstexprnoexcept

Returns nanoseconds (from 0 to 999'999'999).

Definition at line 140 of file time_of_day.hpp.

◆ operator Duration()

proto_structs::TimeOfDay::operator Duration ( ) const
inlineexplicitnodiscardconstexprnoexcept

Explicit conversion to userver::proto_structs::Duration.

Definition at line 190 of file time_of_day.hpp.

◆ operator TDuration()

template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr proto_structs::TimeOfDay::operator TDuration ( ) const
inlineexplicitnodiscardconstexprnoexcept

Explicit conversion to std::chrono::duration.

Definition at line 178 of file time_of_day.hpp.

◆ operator TTimeOfDay() [1/2]

template<typename TTimeOfDay>
requires ::meta::kIsInstantiationOf< std::chrono::hh_mm_ss, TTimeOfDay > constexpr proto_structs::TimeOfDay::operator TTimeOfDay ( ) const
inlineexplicitnodiscardconstexprnoexcept

Explicit conversion to std::chrono::hh_mm_ss.

Definition at line 171 of file time_of_day.hpp.

◆ operator TTimeOfDay() [2/2]

template<typename TTimeOfDay>
requires ::meta::kIsInstantiationOf< utils::datetime::TimeOfDay, TTimeOfDay > constexpr proto_structs::TimeOfDay::operator TTimeOfDay ( ) const
inlineexplicitnodiscardconstexprnoexcept

Explicit conversion to userver::utils::datetime::TimeOfDay.

Definition at line 185 of file time_of_day.hpp.

◆ Seconds()

const std::chrono::seconds & proto_structs::TimeOfDay::Seconds ( ) const
inlinenodiscardconstexprnoexcept

Returns seconds (from 0 to 59 in most cases, however 60 is also valid to support APIs with leap-seconds support).

Definition at line 137 of file time_of_day.hpp.

◆ ToChronoDuration()

template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr TDuration proto_structs::TimeOfDay::ToChronoDuration ( ) const
inlinenodiscardconstexprnoexcept

Converts time of the day to std::chrono::duration.

Definition at line 152 of file time_of_day.hpp.

◆ ToChronoTimeOfDay()

template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr std::chrono::hh_mm_ss< TDuration > proto_structs::TimeOfDay::ToChronoTimeOfDay ( ) const
inlinenodiscardconstexprnoexcept

Converts time of the day to std::chrono::hh_mm_ss.

Definition at line 145 of file time_of_day.hpp.

◆ ToUserverDuration()

Duration proto_structs::TimeOfDay::ToUserverDuration ( ) const
inlinenodiscardconstexprnoexcept

Converts time of the day to userver::proto_structs::Duration.

Definition at line 164 of file time_of_day.hpp.

◆ ToUserverTimeOfDay()

template<typename TDuration = std::chrono::nanoseconds>
requires ::meta::kIsInstantiationOf< std::chrono::duration, TDuration > constexpr utils::datetime::TimeOfDay< TDuration > proto_structs::TimeOfDay::ToUserverTimeOfDay ( ) const
inlinenodiscardconstexprnoexcept

Converts time of the day to userver::utils::datetime::TimeOfDay.

Definition at line 159 of file time_of_day.hpp.


The documentation for this class was generated from the following files: