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

Universal Coordinated Time (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 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 local time is 12 or 13 hours ahead 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 UTCToLocal for a date 6 months ago (or even one week ago), may not give you the correct result.

Declaration: Function UTCToLocal(const AValue: TDateTime): TDateTime

procedure OnMapEvent(var Value:Variant);
var
ThisDate : TDateTime;
begin
{If NOW() is a UTC of 2024-06-25 02:15:16 (i.e. 2:15 a.m. UTC then
the result is 2024-06-25 14:15:16 (i.e. 2:15 p.m. in NZ Standard Time)
But if NOW() is 2024-12-25 02:15:16 (i.e. 2:15 a.m. UTC then
the result is 2024-12-25 01:15:16 (i.e. 3:15 p.m. NZ Daylight Saving Time)}
 
ThisDate := UTCToLocal(Now);
LogInfo(FormatDateTime('dd-mm-yyyy hh:nn:ss.zzz', ThisDate));
LogInfo('');
 
end;