diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2012-06-11 15:09:00 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2012-06-11 15:09:00 -0700 |
commit | 9a1ea4baf8207eb9db8167f7de00ac72c532932f (patch) | |
tree | 6fc4c95850aeb5fb84ea5642bbb6f7976db851f5 /src/include | |
parent | d2b6e49c81a6e43a6241e6573cb2368d6189edb0 (diff) | |
download | ceph-9a1ea4baf8207eb9db8167f7de00ac72c532932f.tar.gz |
rgw: usage log cleanups
Also, recalc_round_timestamp should be done under lock.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/utime.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/include/utime.h b/src/include/utime.h index 6953a9bcf63..f88c9290a65 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -99,6 +99,25 @@ public: tv.tv_nsec = t->tv_nsec; } + utime_t round_to_minute() { + struct tm bdt; + time_t tt = sec(); + gmtime_r(&tt, &bdt); + bdt.tm_sec = 0; + tt = mktime(&bdt); + return utime_t(tt, 0); + } + + utime_t round_to_hour() { + struct tm bdt; + time_t tt = sec(); + gmtime_r(&tt, &bdt); + bdt.tm_sec = 0; + bdt.tm_min = 0; + tt = mktime(&bdt); + return utime_t(tt, 0); + } + // cast to double operator double() { return (double)sec() + ((double)nsec() / 1000000000.0L); |