November 8th, 2016

Why do my file creation, access, or modified time disappear if I set it to midnight on January 1, 1980?

A customer discovered that if their program used the Set­File­Time function to set a network file’s creation, access, or modified time to the specific value of “midnight on January 1, 1980”, then the corresponding timestamp is removed. What’s up with that?

As you may recall, midnight on January 1, 1980 is a special sentinel value: It is the epoch for the MS-DOS time/date format.

At this point, I believe the responsible thing to do is to speculate irresponsibly.

It appears that the network server they are using is trying very hard to accommodate MS-DOS clients. In particular, if somebody tries to set a file timestamp to midnight January 1, 1980, the server assumes that the client is trying to clear the timestamp.

Explorer is one of those accommodating programs. If it sees a file whose timestamp is exactly January 1, 1980 at midnight, then it assumes that the timestamp came from a FAT filesystem (possibly tunnelled through other file systems along the way, like a network redirector), and treats it as equivalent to a missing timestamp.

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.