FB_TzSpecificLocalTimeToSystemTime
The function block converts the local time (structured system time format) to UTC time (structured system time format), taking into account the specified time zone information. The function block: FB_TzSpecificLocalTimeToFileTime has similar functionality but uses a different time format (file time format).
The function block is only suitable for conversion of continuous local timestamp information. Step changes in local time caused by summer/winter time changeover are permitted and are correctly detected by the function block. Arbitrary changes in local time result in incorrect conversion. The reason: the last converted time is stored internally in function block in order to be able to identify the summer time/winter time information and the B times (see below) when the local time is reset. 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.
The step changes in the local time are problematic, since they have to be converted to a linear UTC time. It is therefore advisable to use the (continuous) UTC time for time stamping tasks and to convert the time to respective local time only for display purposes (e.g. in a visualization).
Further information can be found in the documentation for the FB_TzSpecificLocalTimeToFileTime function block.
Inputs
VAR_INPUT
in : TIMESTRUCT;
tzInfo : ST_TimeZoneInformation;
END_VAR
Name | Type | Description |
---|---|---|
in | Local time (structured system time format) to be converted | |
tzInfo | Structure variable with the current time zone information of the operating system. |
Outputs
VAR_OUTPUT
out : TIMESTRUCT;
eTzID : E_TimeZoneID := eTimeZoneID_Unknown;
bB : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
out | Converted UTC time (structured system time format) | |
eTzID | Additional summer/winter time information. | |
bB | BOOL | 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 := 16, wMinute := 46, wSecond := 31, wMilliseconds := 99 );(* Local time *)
out : TIMESTRUCT;(* UTC time result is:= ( wYear := 2011, wMonth := 4, wDay := 29, wHour := 14, wMinute := 46, wSecond := 31, wMilliseconds := 99 ) *)
fbToUTC : FB_TzSpecificLocalTimeToSystemTime;
END_VAR
fbToUTC( 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) |