time struct
A local time-of-day.
Constructors, destructors, conversion operators
- time() defaulted noexcept
- Default constructor. Does not initialize the members.
- 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::auto to_chrono() const → optional<std::
chrono:: nanoseconds> chrono:: hh_mm_ss<Duration>> constexpr noexcept - Converts the time to a std::
chrono:: hh_mm_ss.
Public variables
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::
| 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