I’m writing a simple wrapper around the Win32 FILETIME structure. boost::datetime has most of what I want, except I need whatever date type I end up using to interpolate with Windows APIs without issues.
To that end, I’ve decided to write my own things for doing this — most of the operations aren’t all that complicated. I’m implementing the TimeSpan – like type at this point, but I’m unsure how I’d implement FileTimeToSystemTime. I could just use the system’s built-in FileTimeToSystemTime function, except FileTimeToSystemTime cannot handle negative dates — I need to be able to represent something like “-12 seconds”.
How should something like this be implemented?
Billy3
Windows SYSTEMTIME and FILETIME data types are intended to represent a particular date and time. They are not really suitable to represent time differences. Time differences are better of as a simple integer representing the number of between two SYSTEMTIMEs or FILETIMEs. might be seconds, or something smaller if you need more precision.
If you need to display a difference to users, simple division and modulus can be used to compute the components.