From: Yehuda Sadeh Date: Thu, 3 Mar 2016 06:26:21 +0000 (-0800) Subject: utime: add conversion methods to/from real_time X-Git-Tag: v10.1.0~73^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0695698d349f6fd44081c3928421e739f9f3d396;p=ceph.git utime: add conversion methods to/from real_time Signed-off-by: Yehuda Sadeh Signed-off-by: Matt Benjamin --- diff --git a/src/include/utime.h b/src/include/utime.h index a60501a63faf..f11cdb8a70a9 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -23,6 +23,7 @@ #include "include/types.h" #include "include/timegm.h" #include "common/strtol.h" +#include "common/ceph_time.h" // -------- @@ -61,6 +62,10 @@ public: tv.tv_sec = v.tv_sec; tv.tv_nsec = v.tv_nsec; } + explicit utime_t(const ceph::real_time& rt) { + ceph_timespec ts = real_clock::to_ceph_timespec(rt); + decode_timeval(&ts); + } utime_t(const struct timeval &v) { set_from_timeval(&v); } @@ -76,6 +81,12 @@ public: tv.tv_nsec = (__u32)((d - (double)tv.tv_sec) * (double)1000000000.0); } + real_time to_real_time() const { + ceph_timespec ts; + encode_timeval(&ts); + return ceph::real_clock::from_ceph_timespec(ts); + } + // accessors time_t sec() const { return tv.tv_sec; } long usec() const { return tv.tv_nsec/1000; }