瀏覽代碼

fixbug:s_gmtoff

ithewei 6 年之前
父節點
當前提交
a1b49e87de
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      base/hlog.c

+ 2 - 2
base/hlog.c

@@ -75,7 +75,7 @@ logger_t* logger_create() {
     int local_hour = local_tm->tm_hour;
     struct tm* gmt_tm = gmtime(&ts);
     int gmt_hour = gmt_tm->tm_hour;
-    s_gmtoff = local_hour - gmt_hour;
+    s_gmtoff = (local_hour - gmt_hour) * SECONDS_PER_HOUR;
 
     logger_t* logger = (logger_t*)malloc(sizeof(logger_t));
     logger_init(logger);
@@ -149,7 +149,7 @@ static void ts_logfile(const char* filepath, time_t ts, char* buf, int len) {
 
 static FILE* shift_logfile(logger_t* logger) {
     time_t ts_now = time(NULL);
-    int interval_days = logger->last_logfile_ts == 0 ? 0 : (ts_now+s_gmtoff) / SECONDS_PER_DAY - (logger->last_logfile_ts + s_gmtoff) / SECONDS_PER_DAY;;
+    int interval_days = logger->last_logfile_ts == 0 ? 0 : (ts_now+s_gmtoff) / SECONDS_PER_DAY - (logger->last_logfile_ts+s_gmtoff) / SECONDS_PER_DAY;;
     if (logger->fp_ == NULL || interval_days > 0) {
         // close old logfile
         if (logger->fp_) {