# std::chrono::time_of_day

From cppreference.com
< cpp‎ | chrono

Defined in header `<chrono>` |  |
template< class Duration > class time_of_day; // not defined | (1) | (since C++20)
template<> class time_of_day<std::chrono::hours>; | (2) | (since C++20)
template<> class time_of_day<std::chrono::minutes>; | (3) | (since C++20)
template<> class time_of_day<std::chrono::seconds>; | (4) | (since C++20)
template< class Rep, class Period > class time_of_day<std::chrono::duration<Rep, Period>>; | (5) | (since C++20)

The class template `time_of_day` splits a std::chrono::duration representing time since midnight into a "broken down" time such as hours:minutes:seconds, with the precision of the split determined by the `Duration` template parameter. It also tracks whether it should be output in a 12-hour time format or a 24-hour time format. It is primarily a formatting tool.

The primary template (1) is not defined; four specializations are provided to handle four different levels of precision.

Each specialization of `time_of_day` is a TriviallyCopyable StandardLayoutType.

The partial specialization (5) only exists if std::chrono::treat_as_floating_point_v<Rep> is false and std::chrono::duration<Rep, Period> is not convertible to std::chrono::seconds.

### Member types

Member type | Definition
`precision` | `Duration`

### Member functions

(constructor) | constructs a `time_of_day` (public member function)
hours minutes seconds subseconds | accesses components of the broken-down time (public member function)
operator precision to_duration | accesses the stored std::chrono::duration (public member function)
make12 make24 | changes the time format used for output (public member function)

### Nonmember functions

operator<< | outputs a `time_of_day` into a stream (function template)

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/time_of_day&oldid=104747"