Skip to content

Commit 474447b

Browse files
committed
linux: free datetime interface from tzset
New OSX Date interface had dropped old Windows specific date tests. Do the same for Linux
1 parent 66bc22e commit 474447b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/Runtime/PlatformAgnostic/Platform/Linux/DateTime.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ namespace DateTime
139139
struct tm time_tm = {0};
140140
bool leap_added;
141141
YMD_TO_TM(ymd, &time_tm, &leap_added);
142-
timelocal(&time_tm); // get zone name for the given date
142+
mktime(&time_tm); // get zone name for the given date
143143
CopyTimeZoneName(data.standardName, &data.standardNameLength, time_tm.tm_zone);
144144
*nameLength = data.standardNameLength;
145145
return data.standardName;
@@ -160,8 +160,7 @@ namespace DateTime
160160
// tm doesn't have milliseconds
161161
int milliseconds = local->time % 1000;
162162

163-
tzset();
164-
time_t utime = timelocal(&local_tm);
163+
time_t utime = mktime(&local_tm);
165164
if (local_tm.tm_isdst)
166165
{
167166
utime -= 3600;
@@ -188,8 +187,8 @@ namespace DateTime
188187
// tm doesn't have milliseconds
189188
int milliseconds = utc->time % 1000;
190189

191-
tzset();
192-
time_t ltime = timegm(&utc_tm);
190+
time_t ltime = mktime(&utc_tm);
191+
ltime += -(utc_tm.tm_isdst * 3600) + (utc_tm.tm_gmtoff);
193192

194193
struct tm local_tm = {0};
195194
localtime_r(&ltime, &local_tm);

0 commit comments

Comments
 (0)