54static std::string
format_timespan(
const std::chrono::duration<Rep, Period>&
span,
bool detailed =
false)
56 if(
span.count() <= 0) {
57 return _(
"timespan^expired");
60 std::vector<t_string> display_text;
61 auto [years, months, weeks, days, hours, minutes, seconds] = chrono::deconstruct_duration<chrono::years, chrono::months, chrono::weeks, chrono::days, std::chrono::hours, std::chrono::minutes, std::chrono::seconds>(
span);
63 const auto push_description = [&display_text, detailed](
const auto& time_component,
const auto& fmt_singular,
const auto& fmt_plural)
65 auto amount = time_component.count();
70 display_text.emplace_back(
VNGETTEXT(fmt_singular, fmt_plural, amount, {{
"num", std::to_string(amount)}}));
82 push_description(years,
N_n(
"timespan^$num year",
"timespan^$num years" )) &&
83 push_description(months,
N_n(
"timespan^$num month",
"timespan^$num months" )) &&
84 push_description(weeks,
N_n(
"timespan^$num week",
"timespan^$num weeks" )) &&
85 push_description(days,
N_n(
"timespan^$num day",
"timespan^$num days" )) &&
86 push_description(hours,
N_n(
"timespan^$num hour",
"timespan^$num hours" )) &&
87 push_description(minutes,
N_n(
"timespan^$num minute",
"timespan^$num minutes")) &&
88 push_description(seconds,
N_n(
"timespan^$num second",
"timespan^$num seconds"));
#define N_n(String1, String2)
static std::string _(const char *str)
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.