[erlang-questions] File creation times under Windows

Johnny Billquist <>
Tue Oct 28 10:55:04 CET 2008


Dave Smith wrote:
> NTFS stores time properly in UTC.  FAT/FAT32 stores in local time. 
> Either way, time should be displayed in local time when 
> file:read_file_info/1 is called. 
> 
> I did a little digging into the driver code an to appears the the 
> FileTimeToLocalTime Win32API to convert the time.  I suspect it is this 
> API call that is the root of the problem.  I don't have a Windows 
> platform to test on, so I can't dig any further, but there is a 
> discussion here <http://www.codeproject.com/KB/datetime/dstbugs.aspx> 
> that might explain the problem more.

Looks like you're right. It's storing the timestamp in UTC, but then 
destroys it when retrieving it, trying to make a local time of it.

Well, still a general bug in Windows, which don't have anything to do 
with Erlang. In fact, from the way Windows seems to behave, you get a 
better result (in this aspect) from FAT than NTFS file systems...

	Johnny

> 
> 
> 
> 2008/10/27 Johnny Billquist < <mailto:>>
> 
>     John Hughes wrote:
>      > I would have expected that, once a file has been created, then
>     its creation
>      > time should remain constant (unless explicitly
>     modified)--wouldn't you? Not
>      > so! At least, not under Windows. Under both XP and Vista, the
>     file creation
>      > time reported by file:read_file_info changes by an hour when
>     daylight saving
>      > time ends (and presumably also when it begins)!
>      >
>      > File system design according to the Principle of Greatest
>     Astonishment,
>      > evidently.
> 
>     I believe that's a basic problem with windows, since it don't actually
>     keep time in UTC, but local time, internally.
> 
>     In short: if you use Windows, that's the way it is. Don't have anything
>     to do with Erlang.
> 
>            Johnny
> 
>     _______________________________________________
>     erlang-questions mailing list
>      <mailto:>
>     http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 




More information about the erlang-questions mailing list