[time.hms.overview] (original) (raw)

30 Time library [time]

30.9 Class template hh_mm_ss [time.hms]

30.9.1 Overview [time.hms.overview]

namespace std::chrono { template<class Duration> class hh_mm_ss { public: static constexpr unsigned fractional_width = see below;using precision = see below;constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} constexpr explicit hh_mm_ss(Duration d);constexpr bool is_negative() const 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;private: bool is_neg; chrono::hours h; chrono::minutes m; chrono::seconds s; precision ss; };}

The hh_mm_ss class template splits a durationinto a multi-field time structure_hours_:minutes:seconds and possibly subseconds, where subseconds will be a duration unit based on a non-positive power of 10.

The Duration template parameter dictates the precision to which the time is split.

A hh_mm_ss models negative durations with a distinct is_negative getter that returns true when the input duration is negative.

The individual duration fields always return non-negative durations even when is_negative() indicates the structure is representing a negative duration.

If Duration is not a specialization of duration, the program is ill-formed.