| description | Learn more about: hh_mm_ss class | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| title | hh_mm_ss class | |||||||||
| ms.date | 06/07/2021 | |||||||||
| f1_keywords |
|
|||||||||
| helpviewer_keywords |
|
|||||||||
| dev_langs |
|
Splits a std::chrono::duration into hours:minutes:seconds, with the precision of the split determined by the Duration template parameter. This class is used primarily as a formatting tool.
Duration must be a specialization of std::chrono::duration.
template<class Duration> class hh_mm_ss; // C++20| Name | Description |
|---|---|
| Constructor | Construct a hh_mm_ss. |
| is_negative | Indicates whether the time duration is negative. |
| hours | Get the hours value. |
| minutes | Get the minutes value. |
| seconds | Get the seconds value. |
| subseconds | Get the subseconds value. |
| to_duration | Return a duration_cast<precision>. |
hh_mm_ss::operator precision |
Returns the precision of this hh_mm_ss. |
| Name | Description |
|---|---|
hh_mm_ss::operator<< |
Output a hh_mm_ss to the given stream. |
Header: <chrono>
Namespace: std::chrono
Compiler Option: /std:c++latest
Constructs a hh_mm_ss.
constexpr explicit hh_mm_ss(Duration d);d
Constructs an hh_mm_ss represents the Duration d with precision defined as duration<common_type_t<Duration::rep, seconds::rep>, ratio<1, 10fractional_width>>
If treat_as_floating_point_v<precision::rep> is true, the precision is initialized with abs(d)-hours()-minutes()-seconds(). Otherwise, the precision is initialized with duration_cast<precision>(abs(d)-hours()-minutes()-seconds())
Get whether the time duration is negative.
constexpr bool is_negative() const noexcept;true if the hh_mm_ss value is negative. Otherwise, false.
Get the hours portion of this hh_mm_ss.
constexpr chrono::hours hours() const noexcept;The hours value of this hh_mm_ss.
Get the minutes portion of this hh_mm_ss.
constexpr chrono::minutes minutes() const noexcept;The minutes value of this hh_mm_ss.
Get the seconds portion of this hh_mm_ss.
constexpr chrono::seconds seconds() const noexcept;The seconds value of this hh_mm_ss.
Get the subseconds portion of this hh_mm_ss.
constexpr precision subseconds() const noexcept;The subseconds value of this hh_mm_ss.
If std::chrono::treat_as_floating_point_v<precision::rep> is true, then this is calculated as abs(d)-hours()-minutes()-seconds(). Otherwise, it's calculated as std::chrono::duration_cast<precision>(abs(d)-hours()-minutes()-seconds())
constexpr explicit operator precision() const noexcept;Returns to_duration
constexpr precision to_duration() const noexcept;If is_neg is true, returns -(h+m+s+ss). Otherwise, returns h+m+s+ss.