38 std::tuple{
N_n(
"timespan^$num year",
"timespan^$num years") },
39 std::tuple{
N_n(
"timespan^$num month",
"timespan^$num months") },
40 std::tuple{
N_n(
"timespan^$num week",
"timespan^$num weeks") },
41 std::tuple{
N_n(
"timespan^$num day",
"timespan^$num days") },
42 std::tuple{
N_n(
"timespan^$num hour",
"timespan^$num hours") },
43 std::tuple{
N_n(
"timespan^$num minute",
"timespan^$num minutes") },
44 std::tuple{
N_n(
"timespan^$num second",
"timespan^$num seconds") },
85 template<
typename Rep,
typename Period>
86 static std::string
format_timespan(
const std::chrono::duration<Rep, Period>& span,
bool detailed =
false)
88 if(span.count() <= 0) {
89 return _(
"timespan^expired");
92 std::vector<t_string> display_text;
93 const auto push_description = [&](
const auto& time_component,
const auto& description)
95 auto amount = time_component.count();
100 const auto& [fmt_singular, fmt_plural] = description;
101 display_text.emplace_back(
VNGETTEXT(fmt_singular, fmt_plural, amount, {{
"num", std::to_string(amount)}}));
106 [&push_description](
auto&&... args) {
#define N_n(String1, String2)
static std::string _(const char *str)
std::chrono::duration< int, std::ratio< 2629746 > > months
std::chrono::duration< int, std::ratio< 31556952 > > years
std::chrono::duration< int, std::ratio< 604800 > > weeks
constexpr auto deconstruct_duration(const std::tuple< Ts... > &, const std::chrono::duration< Rep, Period > &span)
std::chrono::duration< int, std::ratio< 86400 > > days
Contains the implementation details for lexical_cast and shouldn't be used directly.
static constexpr auto deconstruct_format
static constexpr std::array descriptors
static std::string format_timespan(const std::chrono::duration< Rep, Period > &span, bool detailed=false)
Formats a timespan into human-readable text for player authentication functions.
std::string format_conjunct_list(const t_string &empty, const std::vector< t_string > &elems)
Format a conjunctive list.