[td-225] fix bugs in parse time

This commit is contained in:
Haojun Liao 2020-06-27 00:15:13 +08:00
parent dc92ea0d8f
commit 4c97427e0c
2 changed files with 11 additions and 12 deletions

View File

@ -20,6 +20,7 @@
#include "tconfig.h"
#include "tutil.h"
// TODO refactor to set the tz value through parameter
void tsSetTimeZone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
uPrint("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);

View File

@ -56,11 +56,9 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
year -= 1;
}
//int64_t res = (((((int64_t) (year/4 - year/100 + year/400 + 367*mon/12 + day) +
// year*365 - 719499)*24 + hour)*60 + min)*60 + sec);
int64_t res;
res = 367*((int64_t)mon)/12;
res += year/4 - year/100 + year/400 + day + year*365 - 719499;
int64_t res = 367*((int64_t)mon)/12;
res += ((int64_t)(year/4 - year/100 + year/400 + day + year*365) - 719499); // this value may be less than 0
res = res*24;
res = ((res + hour) * 60 + min) * 60 + sec;