Merge pull request #5009 from taosdata/hotfix/sangshuduo/TD-2696-fix-RFC3339-timestamp-bug

[TD-2696] <fix>: fix RFC3339 timestamp bug.
This commit is contained in:
Shengliang Guan 2021-01-24 17:10:26 +08:00 committed by GitHub
commit 50ce305ea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -43,7 +43,7 @@
*/ */
int64_t user_mktime64(const unsigned int year0, const unsigned int mon0, int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
const unsigned int day, const unsigned int hour, const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec) const unsigned int min, const unsigned int sec, int64_t timezone)
{ {
unsigned int mon = mon0, year = year0; unsigned int mon = mon0, year = year0;
@ -61,12 +61,6 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
res = res*24; res = res*24;
res = ((res + hour) * 60 + min) * 60 + sec; res = ((res + hour) * 60 + min) * 60 + sec;
#ifdef _MSC_VER
#if _MSC_VER >= 1900
int64_t timezone = _timezone;
#endif
#endif
return (res + timezone); return (res + timezone);
} }
@ -219,7 +213,7 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
/* mktime will be affected by TZ, set by using taos_options */ /* mktime will be affected by TZ, set by using taos_options */
#ifdef WINDOWS #ifdef WINDOWS
int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
//int64_t seconds = gmtime(&tm); //int64_t seconds = gmtime(&tm);
#else #else
int64_t seconds = timegm(&tm); int64_t seconds = timegm(&tm);
@ -276,7 +270,13 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
return -1; return -1;
} }
int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); #ifdef _MSC_VER
#if _MSC_VER >= 1900
int64_t timezone = _timezone;
#endif
#endif
int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, timezone);
int64_t fraction = 0; int64_t fraction = 0;
@ -574,4 +574,4 @@ const char* fmtts(int64_t ts) {
} }
return buf; return buf;
} }