FB_TzSpecificLocalTimeToFileTime64

FB_TzSpecificLocalTimeToFileTime64 1:

The function block converts the local time (file time format) to UTC time (file time format), taking into account the specified time zone information. The function block FB_TzSpecificLocalTimeToSystemTime has similar functionality but converts a different time format (structured system 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).

1. Graphic representation of the changeover from summer time to winter time (tzInfo = WEST_EUROPE_TZI):

FB_TzSpecificLocalTimeToFileTime64 2:

The local time (green) jumps back. The UTC output time (red) continuous. 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):

FB_TzSpecificLocalTimeToFileTime64 3:

The local time (green) jumps forward. The UTC output time (red) continuous. 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).

FB_TzSpecificLocalTimeToFileTime64 4: Inputs

VAR_INPUT
    in     : T_FILETIME64;
    tzInfo : ST_TimeZoneInformation;
END_VAR

Name

Type

Description

in

T_FILETIME

Local time (file time format) to be converted.

tzInfo

ST_TimeZoneInformation

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

FB_TzSpecificLocalTimeToFileTime64 5: Outputs

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

Name

Type

Description

out

T_FILETIME

Converted UTC time (file time format)

eTzID

E_TimeZoneID

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 local time: DT#2011-09-02-11:01:31 is converted UTC time: DT#2011-09-02-09:01:31.

     PROGRAM MAIN
VAR
    in      : DT := DT#2011-09-02-11:01:31;(* Local time *)
    out     : DT;(* UTC time *)
    fbToUTC : FB_TzSpecificLocalTimeToFileTime64;
END_VAR
     fbToUTC( in := DT_TO_FILETIME64( in ), tzInfo := WEST_EUROPE_TZI );
out := FILETIME64_TO_DT( fbToUTC.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