Skip to content

Commit

Permalink
linux: free datetime interface from tzset
Browse files Browse the repository at this point in the history
New OSX Date interface had dropped old Windows specific date tests. Do the same for Linux
  • Loading branch information
obastemur committed Jul 24, 2017
1 parent 66bc22e commit 25b88e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/Runtime/PlatformAgnostic/Platform/Linux/DateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace DateTime
struct tm time_tm = {0};
bool leap_added;
YMD_TO_TM(ymd, &time_tm, &leap_added);
timelocal(&time_tm); // get zone name for the given date
mktime(&time_tm); // get zone name for the given date
CopyTimeZoneName(data.standardName, &data.standardNameLength, time_tm.tm_zone);
*nameLength = data.standardNameLength;
return data.standardName;
Expand All @@ -160,8 +160,7 @@ namespace DateTime
// tm doesn't have milliseconds
int milliseconds = local->time % 1000;

tzset();
time_t utime = timelocal(&local_tm);
time_t utime = mktime(&local_tm);
if (local_tm.tm_isdst)
{
utime -= 3600;
Expand All @@ -188,8 +187,8 @@ namespace DateTime
// tm doesn't have milliseconds
int milliseconds = utc->time % 1000;

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

struct tm local_tm = {0};
localtime_r(&ltime, &local_tm);
Expand Down
4 changes: 2 additions & 2 deletions test/Date/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<baseline>DateGetSet.baseline</baseline>
<!-- test is timezone-sensitive; remove exclude_jenkins after fix (Microsoft/ChakraCore#319) -->
<!-- OSX doesn't provide expected DST info for year 35816 -->
<tags>exclude_jenkins,exclude_mac</tags>
<tags>exclude_jenkins,exclude_xplat</tags>
</default>
</test>
<test>
Expand Down Expand Up @@ -45,7 +45,7 @@
<baseline>parseISO.baseline</baseline>
<!-- test is timezone-sensitive; remove exclude_jenkins after fix (Microsoft/ChakraCore#319) -->
<!-- OSX doesn't provide expected DST for minus years -->
<tags>exclude_jenkins,exclude_mac,Slow</tags>
<tags>exclude_jenkins,exclude_xplat,Slow</tags>
</default>
</test>
<test>
Expand Down

0 comments on commit 25b88e8

Please sign in to comment.