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. Does anyone have a clue(or algorhithm)for how this is converted to something a little more POSIX-like ? Thank you, Derek -- Derek N. Eder Gothenburg University VINKLA - Vigilance and Neurocognition laboratory SU/Sahlgrenska Utvecklingslab 1, Med Gr?na str?ket 8 SE 413 45 G?teborg (Gothenburg) Sverige (Sweden) +46 (031)* 342 8261 (28261 inom Sahlgrenska) +46 0704 915 714 (mobile) +46 (031) 25 97 07 (home) * omit the 0 when calling from outside Sweden personal web page: www.derek-eder.org
One way might be to convert the number to POSIXct by scaling it based that POSIXct is from 1970 and your number is from 1601. So if you subtract the difference between 1601 and 1970 then you should have a compliant number for R: # read your number x <- 12345678901234567890 # big number (your 64-bit time) x.sec <- x / 10^9 # convert to seconds xBase <- unclass(as.POSIXct('1601-1-1')) # your time base, relative to 1970 x.sec <- x.sec - abs(xBase) # scale to 1970 x.time <- structure(x.sec, class=c("POSIXt", "POSIXct")) # convert to POSIXct On 10/19/06, Derek Eder <derek.eder at lungall.gu.se> 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. > > Does anyone have a clue(or algorhithm)for how this is converted to > something a little more POSIX-like ? > > Thank you, > > Derek > > -- > Derek N. Eder > > Gothenburg University > VINKLA - Vigilance and Neurocognition laboratory > > SU/Sahlgrenska > Utvecklingslab 1, Med > Gr?na str?ket 8 > SE 413 45 G?teborg (Gothenburg) > Sverige (Sweden) > > +46 (031)* 342 8261 (28261 inom Sahlgrenska) > +46 0704 915 714 (mobile) > +46 (031) 25 97 07 (home) > > * omit the 0 when calling from outside Sweden > > personal web page: www.derek-eder.org > > ______________________________________________ > R-help at 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
On Thu, 19 Oct 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. > > Does anyone have a clue(or algorhithm)for how this is converted to > something a little more POSIX-like ?ISOdatetime(1601, 1, 1, 0, 0, "UTC") + x/1e7 looks about right, although you won't manage to get the full 64-bit time into R. However, you can also use Windows system calls such as FileTimeToSystemTime to do the conversion. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
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