LocalToUTC returns the date and time value in Universal Coordinated Time (UTC) that corresponds to the given local date and time as specified by AValue.

UTC is the base time and time-zone from which the other time-zones around the world are defined and calculated. For almost all practical purposes, UTC is equivalent to the older term of Greenwich Mean Time, or GMT.

UTC never has Daylight Time or Daylight Saving Time applied to it, whereas local time-zones can have alternating periods of Standard Time and Daylight (Saving) Time.

This function will use the time-zone setting from the Windows operating system on the Statelake server, at the time that the function is called.

This function is not intended to be used for date calculations away from the current local time, because it will not adjust for any changes in time-zone settings that have occurred during the intervening period. So while the function may appear to give a correct UTC time for a future TDateTime value, it may not actually be correct. And the value returned for a retrospective TDateTime value will be based on the current time zone - and may also return an incorrect UTC time.

So regardless of whether the UTC time is 12 or 13 hours behind for the specified date AValue, this function will only apply the rule that is current at the time that the function is called.

i.e. Calling LocalToUTC for a date 6 months ago (or even one week ago), may not give you the correct result.

Declaration: Function LocalToUTC(const AValue: TDateTime): TDateTime;

A simple example follows.

procedure OnMapEvent(var Value:Variant);
begin
{If NOW() is 2024-06-25 14:15:16 (i.e. 2:15 pm local NZ Standard Time) then
the result is 2024-06-25 02:15:16 (i.e. 2:15 a.m. UTC)
But if NOW() is 2024-12-25 14:15:16 (i.e. 2:15 pm local NZ Daylight Time)
then the result is 2024-12-25 01:15:16 (i.e. 1:15 a.m. UTC)}
Value := LocalToUTC(Now);
end;