Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MediaArea/ZenLib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJérôme Martinez <jerome@mediaarea.net>2020-03-03 14:39:28 +0300
committerJérôme Martinez <jerome@mediaarea.net>2020-03-03 14:44:23 +0300
commit70868fe21d8c58373389dd318a76695136580a4b (patch)
tree859d47b03873f025fa90fe811ae6ddec269f8bc5 /Source
parentce8a4e8908829b786b7cd88d6fdae423e701df2f (diff)
x Ztring: some date conversion methods were not thread safe
Diffstat (limited to 'Source')
-rw-r--r--Source/ZenLib/Ztring.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/ZenLib/Ztring.cpp b/Source/ZenLib/Ztring.cpp
index ed34062..7dfb720 100644
--- a/Source/ZenLib/Ztring.cpp
+++ b/Source/ZenLib/Ztring.cpp
@@ -1306,7 +1306,16 @@ Ztring& Ztring::Date_From_Seconds_1970 (const int32s Value)
Ztring& Ztring::Date_From_Seconds_1970 (const int64s Value)
{
time_t Time=(time_t)Value;
+ #if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE
+ struct tm Gmt_Temp;
+ struct tm *Gmt=gmtime_r(&Time, &Gmt_Temp);
+ #elif defined(_WIN32)
+ struct tm Gmt_Temp;
+ errno_t gmtime_s_Result=gmtime_s(&Gmt_Temp , &Time);
+ struct tm* Gmt=gmtime_s_Result?NULL:&Gmt_Temp;
+ #else
struct tm *Gmt=gmtime(&Time);
+ #endif
if (!Gmt)
{
clear();
@@ -1337,7 +1346,16 @@ Ztring& Ztring::Date_From_Seconds_1970 (const int64s Value)
Ztring& Ztring::Date_From_Seconds_1970_Local (const int32u Value)
{
time_t Time=(time_t)Value;
+ #if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE
+ struct tm Gmt_Temp;
+ struct tm *Gmt=localtime_r(&Time, &Gmt_Temp);
+ #elif defined(_WIN32)
+ struct tm Gmt_Temp;
+ errno_t localtime_s_Result=localtime_s(&Gmt_Temp , &Time);
+ struct tm* Gmt=localtime_s_Result?NULL:&Gmt_Temp;
+ #else
struct tm *Gmt=localtime(&Time);
+ #endif
Ztring DateT;
Ztring Date;
Date+=Ztring::ToZtring((Gmt->tm_year+1900));