summaryrefslogtreecommitdiff
path: root/src/mmo/human_time_diff.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mmo/human_time_diff.hpp')
-rw-r--r--src/mmo/human_time_diff.hpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/mmo/human_time_diff.hpp b/src/mmo/human_time_diff.hpp
index 689b8d9..b5c19fb 100644
--- a/src/mmo/human_time_diff.hpp
+++ b/src/mmo/human_time_diff.hpp
@@ -1,5 +1,4 @@
-#ifndef TMWA_MMO_HUMAN_TIME_DIFF_HPP
-#define TMWA_MMO_HUMAN_TIME_DIFF_HPP
+#pragma once
// human_time_diff.hpp - broken deltas
//
// Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
@@ -19,12 +18,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-# include "../sanity.hpp"
+#include "fwd.hpp"
-# include "../strings/xstring.hpp"
+#include <algorithm>
-# include "extract.hpp"
+#include "../strings/xstring.hpp"
+#include "extract.hpp"
+
+
+namespace tmwa
+{
struct HumanTimeDiff
{
short year, month, day, hour, minute, second;
@@ -61,26 +65,25 @@ bool extract(XString str, HumanTimeDiff *iv)
str = str.xislice_t(it2);
short *ptr = nullptr;
- if (suffix == "y" || suffix == "a")
+ if (suffix == "y"_s || suffix == "a"_s)
ptr = &iv->year;
- else if (suffix == "m")
+ else if (suffix == "m"_s)
ptr = &iv->month;
- else if (suffix == "j" || suffix == "d")
+ else if (suffix == "j"_s || suffix == "d"_s)
ptr = &iv->day;
- else if (suffix == "h")
+ else if (suffix == "h"_s)
ptr = &iv->hour;
- else if (suffix == "mn")
+ else if (suffix == "mn"_s)
ptr = &iv->minute;
- else if (suffix == "s")
+ else if (suffix == "s"_s)
ptr = &iv->second;
else
return false;
- if (number.startswith('+') && !number.startswith("+-"))
+ if (number.startswith('+') && !number.startswith("+-"_s))
number = number.xslice_t(1);
if (*ptr || !extract(number, ptr))
return false;
}
return true;
}
-
-#endif // TMWA_MMO_HUMAN_TIME_DIFF_HPP
+} // namespace tmwa