27 Time library [time]

27.9 Class template time_­of_­day [time.tod]

27.9.5 Sub-second precision [time.tod.subsecond]

namespace std::chrono {
  template<class Rep, class Period>
  class time_of_day<duration<Rep, Period>> {
  public:
    using precision = duration<Rep, Period>;

    time_of_day() = default;
    constexpr explicit time_of_day(precision since_midnight) noexcept;

    constexpr chrono::hours     hours()      const noexcept;
    constexpr chrono::minutes   minutes()    const noexcept;
    constexpr chrono::seconds   seconds()    const noexcept;
    constexpr precision subseconds() const noexcept;

    constexpr explicit operator  precision()   const noexcept;
    constexpr          precision to_duration() const noexcept;

    constexpr void make24() noexcept;
    constexpr void make12() noexcept;
  };
}
This specialization shall not exist unless treat_­as_­floating_­point_­v<Rep> is false and duration<Rep, Period> is not convertible to seconds.
[Note
:
This specialization handles hours, minutes, seconds, and fractional seconds since midnight.
Typical uses are with milliseconds, microseconds and nanoseconds.
end note
]
constexpr explicit time_of_day(precision since_midnight) noexcept;
Effects: Constructs an object of type time_­of_­day in 24-hour format corresponding to since_­midnight fractional seconds after 00:00:00.
Ensures: hours() returns the integral number of hours since_­midnight is after 00:00:00.
minutes() returns the integral number of minutes since_­midnight is after (00:00:00 + hours()).
seconds() returns the integral number of seconds since_­midnight is after (00:00:00 + hours() + minutes()).
subseconds() returns the integral number of fractional seconds since_­midnight is after (00:00:00 + hours() + minutes() + seconds()).
constexpr chrono::hours hours() const noexcept;
Returns: The stored hour of *this.
constexpr chrono::minutes minutes() const noexcept;
Returns: The stored minute of *this.
constexpr chrono::seconds seconds() const noexcept;
Returns: The stored second of *this.
constexpr duration<Rep, Period> subseconds() const noexcept;
Returns: The stored subsecond of *this.
constexpr explicit operator precision() const noexcept;
Returns: The number of subseconds since midnight.
constexpr precision to_duration() const noexcept;
Returns: precision{*this}.
constexpr void make24() noexcept;
Effects: If *this is a 12-hour time, converts to a 24-hour time.
Otherwise, no effects.
constexpr void make12() noexcept;
Effects: If *this is a 24-hour time, converts to a 12-hour time.
Otherwise, no effects.