From 77dcfdf5fd96c831ba827e91430162e0a72c2d37 Mon Sep 17 00:00:00 2001 From: cgm <2958580318@qq.com> Date: Tue, 28 Sep 2021 14:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=A4=A9=E6=95=B0=E4=B8=BA1=E6=97=B6=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=86=E5=8F=B2=E6=96=87=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Util/logger.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Util/logger.cpp b/src/Util/logger.cpp index 79c7a6f..2673d01 100644 --- a/src/Util/logger.cpp +++ b/src/Util/logger.cpp @@ -412,7 +412,7 @@ size_t FileChannelBase::size() { ///////////////////FileChannel/////////////////// static const auto s_second_per_day = 24 * 60 * 60; -static long s_gmtoff = 0; +static long s_gmtoff = 0;//时间差 static onceToken s_token([](){ #ifdef _WIN32 TIME_ZONE_INFORMATION tzinfo; @@ -426,7 +426,7 @@ static onceToken s_token([](){ if (dwStandardDaylight == TIME_ZONE_ID_DAYLIGHT) { bias += tzinfo.DaylightBias; } - s_gmtoff = -bias * 60; + s_gmtoff = -bias * 60;//时间差(分钟) #else s_gmtoff = getLocalTime(time(NULL)).tm_gmtoff; #endif // _WIN32 @@ -456,12 +456,12 @@ static time_t getLogFileTime(const string &full_path){ tm.tm_mon = tm_mon - 1; tm.tm_mday = tm_mday; //本地时间转换成GMT时间 - return mktime(&tm) - s_gmtoff; + return mktime(&tm) + s_gmtoff;//UTC时间+时间差 } //获取1970年以来的第几天 static uint64_t getDay(time_t second) { - return (second + s_gmtoff) / s_second_per_day; + return (second - s_gmtoff) / s_second_per_day;//GMT时间-时间差 } FileChannel::FileChannel(const string &name, const string &dir, LogLevel level) : FileChannelBase(name, "", level) { -- Gitee