Accurately serializing and deserializing a SysTime in binary format

drug drug2004 at bk.ru
Tue Jul 21 12:08:56 UTC 2020


On 7/21/20 2:44 PM, Ecstatic Coder wrote:
> 
> Ah thanks for telling me :)
> 
> The loaded byte array in the union type was indeed the same as the saved 
> one, so I immediately thought it was crashing because of some hidden 
> pointer for timezone or something which was then pointing to garbage at 
> reloading, causing the crash of the ".toISOString" call.
> 
> 

Ah, sorry, I serialize exactly long value and use it as SysTime, for 
example:
```D
struct Foo
{
	long value;

	void toString(Writer)(ref Writer w) const
		if (isOutputRange!(Writer, char))
	{
		import std.datetime: SysTime;

		value.SysTime.toUTC.toISOExtString(w);
	}
}
```

So it is not exactly what you said


More information about the Digitalmars-d-learn mailing list