FB_FileTime64ToTzSpecificLocalTime
The function block converts the UTC time (file time format) to local time (file time format), taking into account the specified time zone information. The function block: FB_SystemTimeToTzSpecificLocalTime has a similar functionality but uses a different time format (structured system 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.
1. Graphic representation of the changeover from summer time to winter time (tzInfo = WEST_EUROPE_TZI):
The UTC input time (green) is continuous. The local time (red) jumps back. The local time: 02h:59m:59s:999ms.. is directly followed by: 02h:00m:00s:000ms.. The times between 2h and 3h occur twice. For example, the duplicate time before the time changeover is referred to as 02:05:00 CEST A and the time after the changeover as 02:05:00 CET B. The output variable bB indicates whether it is the first or second pass. During the second pass the bB output variable (blue) is set to TRUE. The bB output variable is automatically reset once the duplicate time has passed. The time zone ID (orange) changes from eTimeZoneID_Daylight (summer time) to eTimeZoneID_Standard (winter time).
2. Graphic representation of the temporal behavior during the change-over from winter time to summer time (tzInfo = WEST_EUROPE_TZI):
The UTC input time (green) is continuous. The local time (green) jumps forward. The local time: 2h:59m:59s:999ms.. is directly followed by: 3h:00m:00s:000ms.. The time zone ID (orange) changes from eTimeZoneID_Standard (winter time) to eTimeZoneID_Daylight (summer time).
Inputs
VAR_INPUT
in : T_FILETIME64;
tzInfo : ST_TimeZoneInformation;
END_VAR
Name | Type | Description |
---|---|---|
in | UTC time (file time format) to be converted. | |
tzInfo | Structure variable with the current time zone information of the operating system. |
Outputs
VAR_OUTPUT
out : T_FILETIME64;
eTzID : E_TimeZoneID := eTimeZoneID_Unknown;
bB : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
out | Converted local time (file 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:
The UTC time: DT#2011-09-02-09:01:31 is converted to local time. The result is: DT#2011-09-02-11:01:31.
PROGRAM MAIN
VAR
in : DT := DT#2011-09-02-09:01:31;(* UTC time *)
out : DT;(* Local time *)
fbToLocal : FB_FileTime64ToTzSpecificLocalTime;
END_VAR
fbToLocal( in := DT_TO_FILETIME64( in ), tzInfo := WEST_EUROPE_TZI );
out := FILETIME64_TO_DT( fbToLocal.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.4024 | PC or CX (x86, x64, ARM) | Tc2_Utilities (System) >= 3.3.44.0 |