Accurately serializing and deserializing a SysTime in binary format

Ecstatic Coder ecstatic.coder at gmail.com
Mon Jul 20 19:04:47 UTC 2020


I'm currently implementing a small open source backup tool (dub), 
and therefore I need to accurately store the file modification 
SysTime in binary format, so that I can later load this SysTime 
from the snapshot file to compare it with the current file 
modification SysTime.

Having unfortunately not understood how to do this from the 
SysTime documentation, in despair, I've tried to directly 
serialize the 16 bytes of the SysTime value. This worked fine 
until I call the ".toISOString()" on the deserialized SysTime, 
which inevitably crashes the executable ;)

Anyway, that's not really want I intended to do, as in practice a 
"ulong" already has enough  resolution for that purpose.

So sorry for my ignorance, but I would definitely need some help 
on how to :
- convert a file modification SysTime to a serializable number, 
for instance the number of hectonanoseconds since 1/1/1970 in UTC;
- convert that number back into a SysTime that I can compare to 
the modification SysTime of the same file.

Eric



More information about the Digitalmars-d-learn mailing list