diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-09-19 10:57:27 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-09-19 11:30:29 -0400 |
commit | faaa1f01daba94b021ca77515266a16d27f0364e (patch) | |
tree | 8eaee16e15cec7d58c2b1eab4d24db78d847ba78 | |
parent | 1111170f2f0141084b5b4ed565b2f07eba48599a (diff) |
util: Add count_seconds time helper
-rw-r--r-- | src/util/time.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/time.h b/src/util/time.h index e4f9996777..c0470a2136 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -11,6 +11,14 @@ #include <chrono> /** + * Helper to count the seconds of a duration. + * + * All durations should be using std::chrono and calling this should generally be avoided in code. Though, it is still + * preferred to an inline t.count() to protect against a reliance on the exact type of t. + */ +inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); } + +/** * DEPRECATED * Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable) */ |