mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-26 07:53:16 +08:00
Suffix d for days duration (#354)
This commit is contained in:
parent
2d282e35fa
commit
f46885e632
@ -8225,7 +8225,6 @@ get_units(std::ratio<3600>)
|
||||
return string_literal<CharT, 2>{'h'};
|
||||
}
|
||||
|
||||
|
||||
template <class CharT>
|
||||
CONSTCD11
|
||||
inline
|
||||
@ -8235,6 +8234,15 @@ get_units(std::ratio<60>)
|
||||
return string_literal<CharT, 4>{'m', 'i', 'n'};
|
||||
}
|
||||
|
||||
template <class CharT>
|
||||
CONSTCD11
|
||||
inline
|
||||
string_literal<CharT, 2>
|
||||
get_units(std::ratio<86400>)
|
||||
{
|
||||
return string_literal<CharT, 2>{'d'};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits = std::char_traits<CharT>>
|
||||
struct make_string;
|
||||
|
||||
|
@ -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<char>(std::ratio<60>{});
|
||||
CONSTCD11 auto h = get_units<char>(std::ratio<3600>{});
|
||||
(void)min, (void)h;
|
||||
CONSTCD11 auto d = get_units<char>(std::ratio<86400>{});
|
||||
(void)min, (void)h, (void)d;
|
||||
|
||||
CONSTCD14 auto integer = get_units<char>(std::ratio<123>{});
|
||||
CONSTCD14 auto ratio = get_units<char>(std::ratio<123, 3>{});
|
||||
|
Loading…
x
Reference in New Issue
Block a user