From 3b8246ab07faa673bf4e11b8aa927a9d724aa7d3 Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Thu, 4 Jul 2019 10:30:23 -0600 Subject: Fix years being offset from weeks (#1678). Currently a duration of 52w will return a blank string. When I added weeks to the calculations, I failed to update the number of seconds to a year. As 365 days and 52 weeks aren't the same, but the calculation needs to be consistent.--- src/helperfuncs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/helperfuncs.cpp') diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 846feab50..386d6dafc 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -432,7 +432,7 @@ bool InspIRCd::IsValidDuration(const std::string& duration) std::string InspIRCd::DurationString(time_t duration) { - time_t years = duration / 31536000; + time_t years = duration / 31449600; time_t weeks = (duration / 604800) % 52; time_t days = (duration / 86400) % 7; time_t hours = (duration / 3600) % 24; -- cgit v1.3.1-10-gc9f91 From 4681faacb542f75cf3ceba6924e3e936a809e01e Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Thu, 4 Jul 2019 10:42:41 -0600 Subject: DurationString(): Return "0s" for a duration of 0 (#1677). Usually a duration of 0 is not allowed or handled separately, but it can also be used as a 'no set time' without separation. Case in point: m_chanhistory calls DurationString() to convert the max time seconds back to a human readable string for the mode serializer. Returning a blank string is bad here. --- src/helperfuncs.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/helperfuncs.cpp') diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 386d6dafc..70ac2f0e6 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -432,6 +432,9 @@ bool InspIRCd::IsValidDuration(const std::string& duration) std::string InspIRCd::DurationString(time_t duration) { + if (duration == 0) + return "0s"; + time_t years = duration / 31449600; time_t weeks = (duration / 604800) % 52; time_t days = (duration / 86400) % 7; -- cgit v1.3.1-10-gc9f91