diff --git a/include/date/date.h b/include/date/date.h index 7b455bf..6b0b4f8 100644 --- a/include/date/date.h +++ b/include/date/date.h @@ -8225,7 +8225,6 @@ get_units(std::ratio<3600>) return string_literal{'h'}; } - template CONSTCD11 inline @@ -8235,6 +8234,15 @@ get_units(std::ratio<60>) return string_literal{'m', 'i', 'n'}; } +template +CONSTCD11 +inline +string_literal +get_units(std::ratio<86400>) +{ + return string_literal{'d'}; +} + template > struct make_string; diff --git a/test/date_test/durations_output.pass.cpp b/test/date_test/durations_output.pass.cpp index f4cbac2..ebf3ff5 100644 --- a/test/date_test/durations_output.pass.cpp +++ b/test/date_test/durations_output.pass.cpp @@ -192,6 +192,14 @@ void test_calendar() assert(os.str() == "13h"); os.str(""); } + + // days + { + days d(13); + os << d; + assert(os.str() == "13d"); + os.str(""); + } } void test_integral_scale() @@ -217,14 +225,6 @@ void test_integral_scale() os.str(""); } - // days = ratio 24 * 60 * 60 / 1 = ratio 86400 / 1 - { - days d(13); - os << d; - assert(os.str() == "13[86400]s"); - os.str(""); - } - // weeks = ratio 7 * 24 * 60 * 60 / 1 = ratio 604800 / 1 { weeks d(13); @@ -310,7 +310,8 @@ void test_constexpr() CONSTCD11 auto min = get_units(std::ratio<60>{}); CONSTCD11 auto h = get_units(std::ratio<3600>{}); - (void)min, (void)h; + CONSTCD11 auto d = get_units(std::ratio<86400>{}); + (void)min, (void)h, (void)d; CONSTCD14 auto integer = get_units(std::ratio<123>{}); CONSTCD14 auto ratio = get_units(std::ratio<123, 3>{});