FB_SystemTimeToTzSpecificLocalTime

FB_SystemTimeToTzSpecificLocalTime 1:

The function block converts the UTC time (structured system time format) to local time (structured system time format), taking into account the specified time zone information. The function block FB_FileTimeToTzSpecificLocalTime has similar functionality but uses a different time format (file time format).

The function block is only suitable for conversion of continuous UTC timestamp information. The function block uses the time zone information to calculate the required time steps (summer/winter time changeover) in local time. Time steps in UTC input time are not permitted and lead to incorrect conversion. The reason: the function block stores the last converted time internally, so that it can detect the B times (see below) from the UTC input time and the stored value when the local time is changed.

The function block is associated with an action: A_Reset(). If this action is called the function block outputs and the locally stored (last converted) time are reset to zero.

FB_SystemTimeToTzSpecificLocalTime 2:

Further information can be found in the documentation for the FB_FileTimeToTzSpecificLocalTime function block.

VAR_INPUT

VAR_INPUT
    in     : TIMESTRUCT;
    tzInfo : ST_TimeZoneInformation;
END_VAR

in: UTC time (structured system time format) to be converted.

tzInfo: Structure variable with the current time zone information of the operating system.

VAR_OUTPUT

VAR_OUTPUT
    out   : TIMESTRUCT;
    eTzID : E_TimeZoneID := eTimeZoneID_Unknown;   
    bB    : BOOL;
END_VAR

out: Converted local time (structured system time format).

eTzID: Additional daylight-saving/standard time information.

bB: TRUE => B time (e.g.:02:05:00 CET B), FALSE => other time (e.g.: 02:05:00 CEST A). This output is set if the local time jumps back and is reset once the duplicate local time has passed.

 

Example:

PROGRAM MAIN
VAR
    in : TIMESTRUCT := ( wYear := 2011, wMonth := 4, wDay := 29, wHour := 14, wMinute := 46, wSecond := 31, wMilliseconds := 99 );(* UTC time *)
    out : TIMESTRUCT; (* Local time result is:= ( wYear := 2011, wMonth := 4, wDay := 29, wHour := 16, wMinute := 46, wSecond := 31, wMilliseconds := 99 ) *)
    fbToLocal : FB_SystemTimeToTzSpecificLocalTime;
END_VAR
fbToLocal( in := in, tzInfo := WEST_EUROPE_TZI, out => out );

 

Further time and time zone functions and function blocks:

FB_TzSpecificLocalTimeToSystemTime, FB_TzSpecificLocalTimeToFileTime, FB_SystemTimeToTzSpecificLocalTime, FB_FileTimeTimeToTzSpecificLocalTime, FB_GetTimeZoneInformation, FB_SetTimeZoneInformation, NT_SetLocalTime, NT_GetTime, NT_SetTimeToRTCTime, F_TranslateFileTimeBias, FB_LocalSystemTime

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v2.11.0 Build > 2036

PC or CX (x86, ARM)

TcUtilities.Lib