Files modified outside Daylight Saving Time show Standard Time in Windows 7 Explorer

3

I have Windows 7 Professional, with automatic updates (so all patches should have been applied). I am in the EST/EDT time zone (New York). The Control Panel time box has "use DST" checked. DST just "sprang forward" on Sunday. I tried applying the patch from last August (KB2863058) and it says it's already installed.

In the Command Prompt (DOS command line) box, "dir" gives what appears to be the correct time for a file I just updated, as well as one updated two months ago (during Standard Time). The clock on the screen lower right corner gives the correct time. However, Windows Explorer gives times one hour earlier for files last modified during Standard Time.

For example,

dir C:\Users\Phil\Desktop\content

gives me

01/24/2014  12:36 PM    4,524  ContentList.txt

while Windows Explorer Desktop > content shows

ContentList.txt    1/24/2014 11:36 AM  Text Document

It's an hour off, as though DST hasn't been applied. Is this a known Windows bug? I haven't seen any reports of it. Since "dir" and WinExp agree on a just-modified file, I think it's WinExp that's off. I used Perl's -M $filename (with $^T) to get the age of files in fractional days, and working the age by hand gives a time two hours later than WinExp (13:36 in the above example). I assume 1 hour is accounted for by DST, but the other?

To summarize, for same file (last modified during Standard Time):

Windows Explorer   11:36 AM
Command Prompt     12:36 PM
Perl -M operator    1:36 PM

For a file modified today, all three times are in agreement. Who's right and who's wrong? I would think that various ways of displaying a time should agree on whether DST is applied.

Phil Perry

Posted 2014-03-12T16:47:55.797

Reputation: 254

Additional info: the stat() command (Perl) behaves the same way as -M (presumably both use the C stat() library call). Files last modified during DST (including previous years) seem to show up the same in all cases. Just files modified during Standard Time period (DST off) seem to show up an hour later on -M and stat and dir, as compared to Windows Explorer. – Phil Perry – 2014-03-12T21:54:15.460

I think I have a workaround of, after computing the timestamp (from -M operator), feeding it to localtime() and checking if the $isdst flag is FALSE. If it is, I need to subtract 1 hour (3600 seconds) from the timestamp. However, I would like to know what combinations of DST for "right now" and "file was modified at" need such an update, and if I have to add 3600 seconds if the file was DST and "now" is not DST. Does anyone know for sure? Or, is there a simpler way to do this? – Phil Perry – 2014-03-12T23:16:38.787

If the Windows Explorer one is an hour earlier, doesn't that imply that Windows Explorer is the correct one and that Command Prompt is incorrectly assuming DST? To me, that seems more likely than saying that Command Prompt is correct and Explorer is unnecessarily removing an our. That is especially true because I would guess that Perl is removing an hour (assuming that the reported time is in DST, when it is in fact correct). – Moshe Katz – 2014-03-13T02:10:42.507

@random, kindly do NOT edit my post and completely change the meaning of it! You can spell out small numbers if you like, but you're not entitled to change my writing. You removed the Perl tag, which is important information. – Phil Perry – 2014-03-13T14:47:48.383

@MosheKatz, yes, sorry if it gave the wrong impression. WinExp (11:36 EST) would more likely be correct, than adding an hour to give 12:36 EDT in January (Perl -M operator and stat call, Command Prompt dir). However, I do not know for sure whether the file was last modified at 11:36 EST or 12:36 EST, and so which is correct. Does WinExp not use the system stat() call (which I presume Perl and Command Prompt do)? – Phil Perry – 2014-03-13T14:53:38.867

1Perl is incidental, and it's not what you are having issues with, merely something you are double-checking with. Also, "bug" is not descriptive of your issue. Trying to make it more evident from the title what you are seeing. – random – 2014-03-13T16:10:12.543

Answers

3

It appears to be a bug with the command prompt DIR results, not with the Windows Explorer.

It's very easy to reproduce:

  • Set your clock back to before DST started, such as March 1st.
  • Create or modify a file.
  • Check the time of your clock, then the file time in the Windows Explorer and with DIR.
  • Set your clock back to today and the correct time.
  • Check the file time again. You'll see that Windows Explorer retains the correct time, but DIR displays it an hour forward.

On NTFS, the file times are all stored in UTC, so it would appear that the DIR command is taking the current date's DST into account when converting the file times from UTC to local time. It should be using the files's time for that decision.

Matt Johnson-Pint

Posted 2014-03-12T16:47:55.797

Reputation: 496

Actually, wouldn't DIR (and the stat call?) be improperly formatting an earlier time as under DST (IOW, treating DST as in effect even when it wasn't)? Next November, when we go back to ST, will DIR show a file saved during DST an hour earlier than it should be? I'm going to have to play with this when I get a chance, to get to the bottom of it. So, a file saved at 11:00 EDT today should be listed as 11:00 under EST, and vice-versa. – Phil Perry – 2014-04-11T14:45:37.673

Updated my answer. It's not that it doesn't take DST into account, it's just that it uses the wrong reference point. – Matt Johnson-Pint – 2014-04-11T14:52:43.853

And sorry, I have very little Perl expertise. My guess is that it has nothing to do with the DIR bug, since the underlying file time on NTFS is always in UTC. – Matt Johnson-Pint – 2014-04-11T14:54:13.010