mirror of
https://github.com/anope/anope.git
synced 2026-06-28 10:46:38 +02:00
Made Anope::Duration also show years
This commit is contained in:
@@ -267,6 +267,7 @@ time_t Anope::DoTime(const Anope::string &s)
|
||||
Anope::string Anope::Duration(time_t t, const NickCore *nc)
|
||||
{
|
||||
/* We first calculate everything */
|
||||
time_t years = t / 31536000;
|
||||
time_t days = (t / 86400);
|
||||
time_t hours = (t / 3600) % 24;
|
||||
time_t minutes = (t / 60) % 60;
|
||||
@@ -278,8 +279,14 @@ Anope::string Anope::Duration(time_t t, const NickCore *nc)
|
||||
{
|
||||
bool need_comma = false;
|
||||
Anope::string buffer;
|
||||
if (years)
|
||||
{
|
||||
buffer = stringify(years) + " " + (years != 1 ? Language::Translate(nc, _("years")) : Language::Translate(nc, _("year")));
|
||||
need_comma = true;
|
||||
}
|
||||
if (days)
|
||||
{
|
||||
buffer += need_comma ? ", " : "";
|
||||
buffer = stringify(days) + " " + (days != 1 ? Language::Translate(nc, _("days")) : Language::Translate(nc, _("day")));
|
||||
need_comma = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user