[R] Time conversion from Win32 64bit FILETIME?
Alberto Monteiro
albmont at centroin.com.br
Thu Oct 19 19:32:45 CEST 2006
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
More information about the R-help
mailing list