-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
File.mtime and friends return a date incorrect by an hour if created half a year ago #2404
Comments
Narrowing down the issue, I wrote a test program only using the JNR POSIX stuff:
Output confirms the wrong times:
Using the pure Java POSIX code, you get the right result:
|
I was not able to reproduce this on JRuby 1.7 HEAD:
I am in US Central Time, which is a daylight savings zone. Does DST need to be active for this to fail? |
That I'm not sure. I have a vague memory of verifying it in both directions, but here I have only reported the case of doing the test during DST. I can probably retest against the same version (and trunk) the next time I have access to the Windows computer. |
1.7.18 when clock is set to May 1 (outside DST):
So yep, both directions. Trying newer builds next. |
Same on 1.7.19, except for an additional warning on the console:
9.0.0.0.pre1 fails to start altogether:
|
Witnessed on 9.0.5.0 as well. Granted, that version is out of date. |
@trejkaz can you try 9.1.9.0 for us? |
Pushing an attempted update into the pipeline to see. Unfortunately I don't have a quick way to run automated tests on Windows and I don't use Windows myself either. When we tried updating to 9.1.6.0, supposedly some clash against Jython caused things to fail, but I'm not sure that was the case so I'm trying anyway. If only travis-ci would add Windows support, I could make a little test project and put the test in it :/ |
@trejkaz you can use appveyor for windows CI and it is free for OSS stuff. |
appveyor looks doable actually. Though that's Windows-only, and I would have preferred to run everything on one CI to get the results in one place. :( Anyway, the overnight run appears to have worked correctly. I get no skew for either of the two files being tested. Hopefully we don't get blocked for updating it by other libraries... (Jython is the most likely trouble-maker because they have a poor policy for keeping their dependencies up to date.) |
Ah, I get a new failure in some other
This, too, works on my box when I run it, so it must be another Windows-specific thing. Failure is:
File another ticket, I guess, and keep waiting? :/ |
9.1.10.0 update fixed the latter issue I got, and my File test still passes, so let's call it done. |
This is a reopen of JRUBY-7064 after verifying that it still occurs on JRuby 1.7.18. The issue appears to be specific to Windows somehow, as noted by someone commenting on the original report. It also only occurs if you live in a region with daylight savings.
Essentially, files created in a different zone offset from the current offset show the wrong time when File.mtime is used. Timestamps on files in NTFS are stored in UTC, so somewhere the wrong time zone is being applied here.
To reproduce, first you must ensure that your time zone is set to one which uses daylight savings (we use Australia/Sydney, because that's where we are.)
Create two files, one during daylight savings and one not. In my case, I just used "touch" to do this:
Verify that the dates have been set correctly. You can verify this in Explorer. "dir" has an off by an hour bug as well, so you should avoid that. I used "ls" since I had it handy:
When running JRuby's irb, you get the wrong time for one of the files (which one is wrong probably depends on the current date):
Notice how it somehow got the offset correct, even though it gets the actual date wrong... that's very weird. Usually you would expect it to get either both wrong or both right. This makes it particularly hard for a script to detect that this has occurred and compensate for it. (I'm not aware of a workaround, in fact.)
MRI (2.0.0 used here, as it's what I happened to have on my Windows install) gets both right:
This relatively simple Java program I whipped up to check if it was Java's fault also gets them right:
Output of that:
The text was updated successfully, but these errors were encountered: