Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix.stat on Windows does not handle timezone and daylight savings time #7569

Closed
vicuna opened this issue Jun 27, 2017 · 3 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Jun 27, 2017

Original bug ID: 7569
Reporter: markghayden
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-06-27T02:01:00Z)
Resolution: duplicate
Priority: normal
Severity: minor
Platform: AMD64
OS: MacOS
OS Version: 10.12.2
Version: 4.04.0
Fixed in version: 4.04.2
Category: otherlibs
Duplicate of: #7385

Bug description

stat.c in otherlibs/win32unix has the following code for converting file times:

if (!FileTimeToLocalFileTime(time, &local) ||
    !FileTimeToSystemTime(&local, &sys))

The MSDN docs (https://msdn.microsoft.com/en-us/library/windows/desktop/ms724277%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) say the following:

Remarks

To account for daylight saving time when converting a file time to a local time, use the following sequence of functions in place of using FileTimeToLocalFileTime:
FileTimeToSystemTime
SystemTimeToTzSpecificLocalTime
SystemTimeToFileTime

Steps to reproduce

  1. Get current time with Unix.gettimeofday
  2. Create a file
  3. Call Unix.stat
  4. Compare stat.st_mtime with the gettimeofday

See attached test file.

Additional information

Output on MacOS is correct:

time0 =1498527385.21647906
time0a=1498527385.00000000 (-0.21647906)
time1 =1498527385.00000000 (-0.21647906)
time2 =1498527385.21670294 (+0.00022388)

Output on Windows is incorrect:

time0 =1498528190.84126230
time0a=1498528190.00000000 (-0.84126234)
time1 =1498513790.00000000 (-14400.84126234) <<<<<<<<<<<<<<<<<<<<
time2 =1498528190.84126230 (+0.00000000)

File attachments

@vicuna
Copy link
Author

vicuna commented Jun 27, 2017

Comment author: @gasche

I believe that this has already been fixed in 4.04.2; could you maybe check?

@vicuna vicuna closed this as completed Jun 27, 2017
@vicuna
Copy link
Author

vicuna commented Jun 27, 2017

Comment author: markghayden

Thanks for pointing this out. I agree this appears to be a duplicate. I had searched on "stat" and other terms but nothing had come up; perhaps I was not using the search feature correctly.

@vicuna
Copy link
Author

vicuna commented Jun 27, 2017

Comment author: @gasche

(I use the google search "site:caml.inria.fr/mantis unix.stat windows". But no criticism here! I am subscribed to the bugtracker emails, so I did remember about the issue; it's much easier to find something when you already know it exists.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants