FB_SystemTimeToTzSpecificLocalTime
![FB_SystemTimeToTzSpecificLocalTime 1:](Images/gif/35587083__en-US__Web.gif)
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 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 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 block is associated with an action: A_Reset(). If this action is called the block outputs and the locally stored (last converted) time are reset to zero.
VAR_INPUT
VAR_INPUT
in : TIMESTRUCT;
tzInfo : ST_TimeZoneInformation;
END_VAR
in: UTC time (structured system time format) to be converted (type: TIMESTRUCT).
tzInfo: Structure variable with the current time zone information of the operating system (type: ST_TimeZoneInformation).
VAR_OUTPUT
VAR_OUTPUT
out : TIMESTRUCT;
eTzID : E_TimeZoneID := eTimeZoneID_Unknown;
bB : BOOL;
END_VAR
out: Converted local time (structured system time format) (type: TIMESTRUCT).
eTzID: Additional summer/winter time information (type: E_TimeZoneID).
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:
Requirements
Development environment |
Target platform |
PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_Utilities (System) |