Re: [R] Time conversion from Win32 64bit FILETIME?

From: Alberto Monteiro <albmont_at_centroin.com.br>
Date: Thu 19 Oct 2006 - 17:32:45 GMT

Derek Eder wrote:
>
> Windows-32 has a time structure called FILETIME, a 64-bit value
> representing the number of 100-nanosecond intervals since January 1,
> 1601 (UTC). That is not a typo, the year is 1601.
>
It could be worse. VAX/VMS used an internal time that was the number of seconds since 1858-11-17 multiplied by 10,000,000 - I don't know what they were smoking when they came to this number.  

> Does anyone have a clue(or algorhithm)for how this is converted to
> something a little more POSIX-like ?
>
I would try to get the meaningful FILETIME for some recent date [like 2001-01-01] and then do a simple arithmetic. The real problem is that there is no _unique_ definition of 1601-01-01, because the Gregorian reform of the calendar was established some years before that, but Redmond didn't change to Gregorian until some date after that. So, there's no way to know if 1601-01-01 is Gregorian or Julian calendar.

If it's Gregorian, then a simple calculation gives that 2001-01-01 would correspond to FILETIME = ((365 * 400) + 100 - 3) * 24 * 60 * 60 * (1e9 / 100)

where:

365 * 400 = number of normal (non-Feb-29) days 100 = number of _Julian_ calendar Feb-29 days -3 = take this off, because 1700, 1800 and 1900 were not leap years

And now I think the problem is much simpler.

Alberto Monteiro



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Oct 20 11:18:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 20 Oct 2006 - 01:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.