fix: fix windows handling localtime_s error
This commit is contained in:
parent
18b039fecd
commit
3bdef853b2
|
@ -33,6 +33,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
//#define TM_YEAR_BASE 1970 //origin
|
//#define TM_YEAR_BASE 1970 //origin
|
||||||
#define TM_YEAR_BASE 1900 // slguan
|
#define TM_YEAR_BASE 1900 // slguan
|
||||||
|
#define _MAX__TIME64_T 0x793406fffi64
|
||||||
|
|
||||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
||||||
// until 00:00:00 January 1, 1970
|
// until 00:00:00 January 1, 1970
|
||||||
|
@ -444,6 +445,9 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result) {
|
||||||
result->tm_yday = 0;
|
result->tm_yday = 0;
|
||||||
result->tm_isdst = 0;
|
result->tm_isdst = 0;
|
||||||
} else {
|
} else {
|
||||||
|
if (*timep > _MAX__TIME64_T) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
localtime_s(result, timep);
|
localtime_s(result, timep);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -500,6 +504,9 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst)
|
||||||
result->tm_yday = 0;
|
result->tm_yday = 0;
|
||||||
result->tm_isdst = 0;
|
result->tm_isdst = 0;
|
||||||
} else {
|
} else {
|
||||||
|
if (*timep > _MAX__TIME64_T) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
localtime_s(result, timep);
|
localtime_s(result, timep);
|
||||||
}
|
}
|
||||||
#elif defined(LINUX)
|
#elif defined(LINUX)
|
||||||
|
|
|
@ -291,7 +291,10 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tm ptm = {0};
|
struct tm ptm = {0};
|
||||||
taosLocalTime(&tt, &ptm);
|
if (taosLocalTime(&tt, &ptm) == NULL) {
|
||||||
|
sprintf(buf, "%s", "NaN");
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
|
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
|
||||||
|
|
||||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||||
|
|
Loading…
Reference in New Issue