summaryrefslogtreecommitdiff
path: root/otherlibs
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2017-02-20 14:38:12 +0100
committerDavid Allsopp <david.allsopp@metastack.com>2017-05-16 19:48:37 +0100
commit946c6eaf5f0f6ab0c832524a0d8c15158cfe9c03 (patch)
treef47fdc102001dc0cc369e9d5d3da9c0af23ea98d /otherlibs
parent6105a2a9e6eb09caf86bee345ae2a4289b49b087 (diff)
downloadocaml-946c6eaf5f0f6ab0c832524a0d8c15158cfe9c03.tar.gz
MPR#7385: fix Unix.stat timestamps during DST
The Win32 API used treats DST as a timezone offset rather than a bias, resulting in all timestamps being an hour out when the system date is during DST.
Diffstat (limited to 'otherlibs')
-rw-r--r--otherlibs/win32unix/stat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/otherlibs/win32unix/stat.c b/otherlibs/win32unix/stat.c
index 7ed2df7028..1630f99852 100644
--- a/otherlibs/win32unix/stat.c
+++ b/otherlibs/win32unix/stat.c
@@ -118,11 +118,11 @@ static value stat_aux(int use_64, __int64 st_ino, struct _stat64 *buf)
static int convert_time(FILETIME* time, __time64_t* result, __time64_t def)
{
SYSTEMTIME sys;
- FILETIME local;
+ SYSTEMTIME utc;
if (time->dwLowDateTime || time->dwHighDateTime) {
- if (!FileTimeToLocalFileTime(time, &local) ||
- !FileTimeToSystemTime(&local, &sys))
+ if (!FileTimeToSystemTime(time, &utc) ||
+ !SystemTimeToTzSpecificLocalTime(NULL, &utc, &sys))
{
win32_maperr(GetLastError());
return 0;
@@ -131,7 +131,7 @@ static int convert_time(FILETIME* time, __time64_t* result, __time64_t def)
{
struct tm stamp = {sys.wSecond, sys.wMinute, sys.wHour,
sys.wDay, sys.wMonth - 1, sys.wYear - 1900,
- 0, 0, 0};
+ 0, 0, -1};
*result = _mktime64(&stamp);
}
}