Skip to content

Commit faaa1f0

Browse files
author
MarcoFalke
committed
util: Add count_seconds time helper
1 parent 1111170 commit faaa1f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/util/time.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
#include <string>
1111
#include <chrono>
1212

13+
/**
14+
* Helper to count the seconds of a duration.
15+
*
16+
* All durations should be using std::chrono and calling this should generally be avoided in code. Though, it is still
17+
* preferred to an inline t.count() to protect against a reliance on the exact type of t.
18+
*/
19+
inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
20+
1321
/**
1422
* DEPRECATED
1523
* Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)

0 commit comments

Comments
 (0)