Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -5469,9 +5469,14 @@ namespace chrono {
void _Write_seconds(basic_ostream<_CharT, _Traits>& _Os, const hh_mm_ss<_Duration>& _Val) {
_Os << _STD format(_STATICALLY_WIDEN(_CharT, "{:02}"), _Val.seconds().count());
if constexpr (hh_mm_ss<_Duration>::fractional_width > 0) {
_Os << _STD format(_STATICALLY_WIDEN(_CharT, "{0}{1:0{2}}"),
_STD use_facet<numpunct<_CharT>>(_Os.getloc()).decimal_point(), _Val.subseconds().count(),
_Val.fractional_width);
_Os << _STD use_facet<numpunct<_CharT>>(_Os.getloc()).decimal_point();
if constexpr (treat_as_floating_point_v<typename hh_mm_ss<_Duration>::precision::rep>) {
_Os << _STD format(_STATICALLY_WIDEN(_CharT, "{:0{}.0f}"), _STD floor(_Val.subseconds().count()),
_Val.fractional_width);
} else {
_Os << _STD format(
_STATICALLY_WIDEN(_CharT, "{:0{}}"), _Val.subseconds().count(), _Val.fractional_width);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@ void test_hh_mm_ss_formatter() {
empty_braces_helper(hh_mm_ss{4083007ms}, STR("01:08:03.007"));
empty_braces_helper(hh_mm_ss{65745123ms}, STR("18:15:45.123"));
empty_braces_helper(hh_mm_ss{65745s}, STR("18:15:45"));
empty_braces_helper(hh_mm_ss{0.1ns}, STR("00:00:00.000000000"));
empty_braces_helper(hh_mm_ss{1.45ns}, STR("00:00:00.000000001"));
empty_braces_helper(hh_mm_ss{1.56ns}, STR("00:00:00.000000001"));
empty_braces_helper(hh_mm_ss{1e+8ns}, STR("00:00:00.100000000"));
empty_braces_helper(hh_mm_ss{999'999.9us}, STR("00:00:00.999999"));
empty_braces_helper(hh_mm_ss{59'999'999.9us}, STR("00:00:59.999999"));
empty_braces_helper(hh_mm_ss{3'599'999'999.9us}, STR("00:59:59.999999"));
empty_braces_helper(hh_mm_ss{86'399'999'999.9us}, STR("23:59:59.999999"));

assert(format(STR("{:%H %I %M %S %r %R %T %p}"), hh_mm_ss{13h + 14min + 15351ms})
== STR("13 01 14 15.351 13:14:15 13:14 13:14:15.351 PM"));
Expand Down