It's 4:20 in the morning, and this is really annoying me. Calling this function produces a debugger exception notification with the following error message:
"Invalid argument to date encode."
The problem line is the call to SystemTimeToDateTime, though I don't see why. TZSystem.StandardDate is a _SYSTEMTIME, and SystemTimeToDateTime wants a _SYSTEMTIME, so what's the problem?
DateTime := SystemTimeToDateTime(TZSystem.StandardDate);