1
0
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:
Adam
2013-01-30 11:24:57 -05:00
parent ae2c82adbc
commit 47af43c281
+7
View File
@@ -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;
}