Skip to content

Commit

Permalink
utime.h: fix timezone issue in round_to_* funcs.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
zhaochao committed Feb 29, 2016
1 parent 1c4ccfe commit c914f28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/include/utime.h
Expand Up @@ -137,7 +137,7 @@ class utime_t {
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);
Expand All @@ -146,7 +146,7 @@ class utime_t {
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);
Expand Down

0 comments on commit c914f28

Please sign in to comment.