Make all test262 tests pass on Windows (#3157)

Changes:
- Implemented jerry_port_get_local_time_zone_adjustment on Windows
- Implemented jerry_port_get_current_time on Windows
- Run test262 tests on Windows in PST/PDT timezone

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
Csaba Osztrogonác
2019-09-26 14:31:22 +02:00
committed by Robert Fancsik
parent 9ab4872244
commit 2b3faf683d
2 changed files with 67 additions and 2 deletions
+44
View File
@@ -16,6 +16,14 @@
#ifdef HAVE_TM_GMTOFF
#include <time.h>
#endif /* HAVE_TM_GMTOFF */
#ifdef _WINDOWS
#include <windows.h>
#include <winbase.h>
#include <winnt.h>
#include <time.h>
#endif /* _WINDOWS */
#ifdef __GNUC__
#include <sys/time.h>
#endif /* __GNUC__ */
@@ -23,6 +31,17 @@
#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
#ifdef _WINDOWS
/* https://support.microsoft.com/en-us/help/167296/how-to-convert-a-unix-time-t-to-a-win32-filetime-or-systemtime */
void UnixTimeToFileTime (LONGLONG t, LPFILETIME pft)
{
LONGLONG ll = t * 10000000 + 116444736000000000;
pft->dwLowDateTime = (DWORD) ll;
pft->dwHighDateTime = ll >> 32;
} /* UnixTimeToFileTime */
#endif /* _WINDOWS */
/**
* Default implementation of jerry_port_get_local_time_zone_adjustment. Uses the 'tm_gmtoff' field
* of 'struct tm' (a GNU extension) filled by 'localtime_r' if available on the
@@ -47,6 +66,25 @@ double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since
#else /* !HAVE_TM_GMTOFF */
(void) unix_ms;
(void) is_utc;
#ifdef _WINDOWS
FILETIME fileTime, localFileTime;
SYSTEMTIME systemTime, localSystemTime;
ULARGE_INTEGER time, localTime;
_tzset ();
UnixTimeToFileTime ((LONGLONG) (unix_ms / 1000), &fileTime);
if (FileTimeToSystemTime (&fileTime, &systemTime)
&& SystemTimeToTzSpecificLocalTime (0, &systemTime, &localSystemTime)
&& SystemTimeToFileTime (&localSystemTime, &localFileTime))
{
time.LowPart = fileTime.dwLowDateTime;
time.HighPart = fileTime.dwHighDateTime;
localTime.LowPart = localFileTime.dwLowDateTime;
localTime.HighPart = localFileTime.dwHighDateTime;
return ((LONGLONG) localTime.QuadPart - (LONGLONG) time.QuadPart) / 10000;
}
#endif /* _WINDOWS */
return 0.0;
#endif /* HAVE_TM_GMTOFF */
} /* jerry_port_get_local_time_zone_adjustment */
@@ -70,5 +108,11 @@ double jerry_port_get_current_time (void)
}
#endif /* __GNUC__ */
#ifdef _WINDOWS
time_t ltime;
time (&ltime);
return ltime * 1000;
#endif /* _WINDOWS */
return 0.0;
} /* jerry_port_get_current_time */