localtime func crash in windows

This commit is contained in:
Shengliang Guan 2020-08-12 05:14:59 +00:00
parent 7da7b6177c
commit f790a124b1
2 changed files with 8 additions and 0 deletions

View File

@ -379,6 +379,10 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
}
*/
#ifdef WINDOWS
if (tt < 0) tt = 0;
#endif
struct tm* ptm = localtime(&tt);
size_t pos = strftime(buf, 32, "%Y-%m-%d %H:%M:%S", ptm);

View File

@ -791,6 +791,10 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
}
*/
#ifdef WINDOWS
if (tt < 0) tt = 0;
#endif
tp = localtime(&tt);
strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", tp);
sprintf(value, "%s.%03d", timeStr,