From c914f28d6e79726b84261884c37b89d7c6b34f21 Mon Sep 17 00:00:00 2001 From: Zhao Chao Date: Thu, 25 Feb 2016 11:17:18 +0800 Subject: [PATCH] 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 --- src/include/utime.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/utime.h b/src/include/utime.h index a60501a63faf6..1a1ad4cb4fa5a 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); -- 2.39.5