]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
utime.h: fix timezone issue in round_to_* funcs. 7789/head
authorZhao Chao <zhaochao1984@gmail.com>
Thu, 25 Feb 2016 03:17:18 +0000 (11:17 +0800)
committerZhao Chao <zhaochao1984@gmail.com>
Mon, 29 Feb 2016 02:43:43 +0000 (10:43 +0800)
gmtime_r converts local time to UTC, however mktime only takes an
argument as local time. Use localtime_r instead of gmtime_r will fix.

Fixes: #14862
Reported-by: isyippee <yippee_liu@163.com>
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
src/include/utime.h

index a60501a63faf6452294a8b26a2f0740a1f9dbb9b..1a1ad4cb4fa5a495d09579a027f7cb588ed55162 100644 (file)
@@ -137,7 +137,7 @@ public:
   utime_t round_to_minute() {
     struct tm bdt;
     time_t tt = sec();
-    gmtime_r(&tt, &bdt);
+    localtime_r(&tt, &bdt);
     bdt.tm_sec = 0;
     tt = mktime(&bdt);
     return utime_t(tt, 0);
@@ -146,7 +146,7 @@ public:
   utime_t round_to_hour() {
     struct tm bdt;
     time_t tt = sec();
-    gmtime_r(&tt, &bdt);
+    localtime_r(&tt, &bdt);
     bdt.tm_sec = 0;
     bdt.tm_min = 0;
     tt = mktime(&bdt);