timeunix-timestampfiletime

Why is the constant 11644473600 used for converting FILETIME to Unix time?


I've been researching on how different operating systems represent time, as well as how to convert between them. I've read several pages that all describe a similar method for converting between FILETIME and Unix time, most notably this post. The logic behind how this works is pretty simple and plainly states that there's been 11644473600 seconds from January 1st, 1601 to January 1st 1970.

My question is: Why is the constant 11644473600 and not 11644732800?

When I divide out 11,644,473,600 seconds, that equals 134,774 days. That would include 92 leap years and comes out to ~368.99 years. Every time I run the numbers myself, the number I come out to for 369 years (which would contain 92 leap years) ends up being 11,644,732,800 seconds (134,777 days).

Am I just doing some bits of math wrong or is there some other bits of information that I haven't read or learned about how this conversion works?

EDIT: As pointed out by Vladimir Posvistelik, my issue was that I wasn't calculating leap years correctly. The years 1700, 1800, and 1900 are NOT leap years. This explains my number being off by three days.


Solution

  • I think they came from the fact, that not all years divisible by 4 are leap. As said on Wikipedia:

    This extra leap day occurs in each year that is an integer multiple of 4 (except for years evenly divisible by 100, but not by 400)