
I have written a function to convert a posix_time::ptime to a windows FILETIME (which is in essence a 64-bit value counting 100-nanosecond intervals since Jan 01, 1601). In order to do so, I do a time difference between the ptime and a time setup to the FILETIME reference time. To convert from this time_duration to the FILETIME count, I use time_duration::rep_type::ticks_per_second. Since this does not seem to be documented I just wanted to make sure I was using it correctly (or if I should be using it at all). Here is my code (which seems to work): const ULONGLONG nanosecPerFileTimeUnit = 100; using namespace boost::posix_time; using namespace boost::gregorian; FILETIME toFileTime ( const ptime& time ) { ptime refTime(date(1601,Jan,01)); time_duration sinceRefDate = time - refTime; ULARGE_INTEGER durationInFileTimeUnits; const ULONGLONG timeDurTicksPerSec = time_duration::rep_type::ticks_per_second; const ULONGLONG fileTimeUnitsPerTimeDurTick = (nanosecPerSec/timeDurTicksPerSec) / nanosecPerFileTimeUnit; durationInFileTimeUnits.QuadPart = sinceRefDate.ticks()*fileTimeUnitsPerTimeDurTick ; FILETIME ft; ft.dwLowDateTime = durationInFileTimeUnits.LowPart; ft.dwHighDateTime = durationInFileTimeUnits.HighPart; return ft; }