diff --git a/cpp/src/db/Meta.cpp b/cpp/src/db/Meta.cpp index 31fdee74a492e28c3dce0b6a255e8728e9265e98..3d272e0637ae3f76c4bbdf069e707db210a8e27e 100644 --- a/cpp/src/db/Meta.cpp +++ b/cpp/src/db/Meta.cpp @@ -4,6 +4,7 @@ * Proprietary and confidential. ******************************************************************************/ #include +#include #include "Meta.h" namespace zilliz { @@ -12,23 +13,24 @@ namespace engine { namespace meta { DateT Meta::GetDate(const std::time_t& t, int day_delta) { - tm *ltm = std::localtime(&t); + struct tm ltm; + localtime_r(&t, <m); if (day_delta > 0) { do { - ++ltm->tm_mday; + ++ltm.tm_mday; --day_delta; } while(day_delta > 0); - mktime(ltm); + mktime(<m); } else if (day_delta < 0) { do { - --ltm->tm_mday; + --ltm.tm_mday; ++day_delta; } while(day_delta < 0); - mktime(ltm); + mktime(<m); } else { - ltm->tm_mday; + ltm.tm_mday; } - return ltm->tm_year*10000 + ltm->tm_mon*100 + ltm->tm_mday; + return ltm.tm_year*10000 + ltm.tm_mon*100 + ltm.tm_mday; } DateT Meta::GetDateWithDelta(int day_delta) {