summaryrefslogtreecommitdiff
path: root/src/misc.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-01-30 11:24:57 -0500
committerAdam <Adam@anope.org>2013-01-30 11:24:57 -0500
commit47af43c2810224ff0f101f8d0ed160100fae6896 (patch)
treed53d68c9c4171a6d3126af7284020bbf87d774fe /src/misc.cpp
parentae2c82adbc42b84ae840d8408d450e5d4c4bbee1 (diff)
Made Anope::Duration also show years
Diffstat (limited to 'src/misc.cpp')
-rw-r--r--src/misc.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/misc.cpp b/src/misc.cpp
index 957410656..18d737dbc 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -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;
}