malcommac / SwiftDate

🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
MIT License
7.61k stars 767 forks source link

Add support for Win32 FILETIME (Windows NT time) time format #808

Open DominikPalo opened 1 year ago

DominikPalo commented 1 year ago

Even though the toolkit supports parsing of many different time formats (including the CSOM DateTime aka .NET DateTime), there is another popular time format used mainly (but not only) on Windows systems called Win32 FILETIME (aka Windows NT time format). It is very similar to CSOM DateTime with one difference - 100-nanosecond ticks are counted from 1 January 1601 00:00:00 UT:

Wikipedia:

Windows 9x and Windows NT, provide the system time as FILETIME, represented as a count of the number of 100-nanosecond ticks since 1 January 1601 00:00:00 UT as reckoned in the proleptic Gregorian calendar.

BTW, there is a nice online converter: https://www.epochconverter.com/ldap

This format is used also on macOS by Microsoft products - for instance, Microsoft Office for Mac uses this format for storing registry keys in the MicrosoftRegistrationDB.reg SQLite database (I had to parse it yesterday in Swift, that's how I bumped into it).

So, It would be nice to support also this format. What do you think?