diff options
Diffstat (limited to '')
-rw-r--r-- | src/base/humanize.time.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/base/humanize.time.hh b/src/base/humanize.time.hh index 96edebd..e1ebf67 100644 --- a/src/base/humanize.time.hh +++ b/src/base/humanize.time.hh @@ -74,12 +74,22 @@ class duration { public: static duration from_tv(const struct timeval& tv); + template<class Rep, class Period> + duration& with_resolution(const std::chrono::duration<Rep, Period>& res) + { + this->d_msecs_resolution + = std::chrono::duration_cast<std::chrono::milliseconds>(res) + .count(); + return *this; + } + std::string to_string() const; private: explicit duration(const struct timeval& tv) : d_timeval(tv) {} struct timeval d_timeval; + uint64_t d_msecs_resolution{1}; }; } // namespace time |