From: Zhao Chao Date: Thu, 25 Feb 2016 03:17:18 +0000 (+0800) Subject: utime.h: fix timezone issue in round_to_* funcs. X-Git-Tag: v11.0.0~531^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F7789%2Fhead;p=ceph.git utime.h: fix timezone issue in round_to_* funcs. 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 Signed-off-by: Zhao Chao --- diff --git a/src/include/utime.h b/src/include/utime.h index a60501a63fa..1a1ad4cb4fa 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -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);