toml::time struct

A local time-of-day.

Constructors, destructors, conversion operators

time() defaulted noexcept
Default constructor. Does not initialize the members.
template <typename H, typename M, typename S = uint8_t, typename NS = uint32_t>
time(H h, M m, S s = S{}, NS ns = NS{}) constexpr noexcept
Constructs a time from individual time component values.
template <typename Duration>
time(std::chrono::hh_mm_ss<Duration> value) constexpr noexcept
Constructs a time from a hh_mm_ss value.

Public functions

template <typename Duration = std::chrono::nanoseconds>
auto to_chrono() const →  optional<std::chrono::hh_mm_ss<Duration>> constexpr noexcept
Converts the time to a std::chrono::hh_mm_ss.

Public variables

uint8_t hour
The hour component, from 0 - 23.
uint8_t minute
The minute component, from 0 - 59.
uint8_t second
The second component, from 0 - 59, or 60 for a leap second.
uint32_t nanosecond
The fractional nanoseconds component, from 0 - 999999999.

Friends

auto operator!=(time lhs, time rhs) →  bool constexpr noexcept
Inequality operator.
auto operator<(time lhs, time rhs) →  bool constexpr noexcept
Less-than operator.
auto operator<<(std::ostream& lhs, const time& rhs) →  std::ostream&
Prints a time out to a stream as HH:MM:SS (per RFC 3339), followed by a fraction of up to nine digits when the nanoseconds are not zero.
auto operator<=(time lhs, time rhs) →  bool constexpr noexcept
Less-than-or-equal-to operator.
auto operator==(time lhs, time rhs) →  bool constexpr noexcept
Equality operator.
auto operator>(time lhs, time rhs) →  bool constexpr noexcept
Greater-than operator.
auto operator>=(time lhs, time rhs) →  bool constexpr noexcept
Greater-than-or-equal-to operator.

Function documentation

template <typename Duration>
toml::time::time(std::chrono::hh_mm_ss<Duration> value) constexpr noexcept

Constructs a time from a hh_mm_ss value.

template <typename Duration = std::chrono::nanoseconds>
optional<std::chrono::hh_mm_ss<Duration>> toml::time::to_chrono() const constexpr noexcept

Converts the time to a std::chrono::hh_mm_ss.

Template parameters
Duration The duration type of the result. Finer parts are truncated.
Returns The time of day, or an empty optional if it is out of range for Duration.

std::ostream& operator<<(std::ostream& lhs, const time& rhs)

Prints a time out to a stream as HH:MM:SS (per RFC 3339), followed by a fraction of up to nine digits when the nanoseconds are not zero.

std::cout << toml::time{ 10, 20, 34 } << "\n";
std::cout << toml::time{ 10, 20, 34, 500000000 } << "\n";
10:20:34
10:20:34.5