Accurately serializing and deserializing a SysTime in binary format

drug drug2004 at bk.ru
Tue Jul 21 11:01:20 UTC 2020


On 7/20/20 10:04 PM, Ecstatic Coder wrote:
> 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 ;)

That is probably a bug. I serialize SysTime as long by means msgpack for 
exchanging between C++ client and D server and it works pretty nice.

> 
> 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