From faaa1f01daba94b021ca77515266a16d27f0364e Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 19 Sep 2019 10:57:27 -0400 Subject: util: Add count_seconds time helper --- src/util/time.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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 @@ -10,6 +10,14 @@ #include #include +/** + * 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 (mockable) -- cgit v1.2.3