UtcTime_To_String

Converts the components of the structured type T_UtcTime into a formatted UTC-Time string. The resulting string has the following structure: 'UT#YYYY-MM-DD-hh:mm:ss.nnnnnnnnn|LFC|A[A]'. It corresponds to the TwinCAT UTC-Time string format specification.

Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)

Syntax

FUNCTION UtcTime_To_String : STRING(39)
VAR_INPUT
    in     : T_UtcTime;
END_VAR
VAR_OUTPUT
    bError : BOOL;
END_VAR

UtcTime_To_String 1: Inputs

Name

Type

Description

in

T_UtcTime

The time information to be converted as a UTC-Time structure.

UtcTime_To_String 2: Outputs

Name

Type

Description

bError

BOOL

The output is "TRUE" if the input value could not be converted without error.

UtcTime_To_String 3: Return value

Name

Type

Description

UtcTime_To_String

STRING(39)

Converted time information as a UTC-Time string.

Sample

'UT#2017-01-16-11:22:33.750000000|001|24' means date "2017-01-16", time "11:22:33" and "750" ms, leap seconds unknown, timer has no error, time is not synchronized.

METHOD UtcTime_ToFrom_String : BOOL
VAR_INPUT
    fbIED : REFERENCE TO FB_IED;
END_VAR
VAR
    tValue : T_UtcTime;
    sValue : STRING;
END_VAR
IF NOT __ISVALIDREF(fbIED) THEN
    RETURN;
END_IF

tValue := String_To_UtcTime('UT#1970-01-01-00:00:00.000000000|000|0');
sValue := UtcTime_To_String(tValue);(* sValue := 'UT#1970-01-01-00:00:00.000000000|000|0' *)
IF fbIED.Relay.LLN0.Beh.t.sValue <> sValue THEN
    tValue := fbIED.Relay.LLN0.Beh.t.tValue;
END_IF

tValue := String_To_UtcTime('UT#2018-03-21-14:56:55.125000000|010|3');(* ClockFailure := 1, accuracy := 3 bits *)
sValue := UtcTime_To_String(tValue);(* sValue := 'UT#2018-03-21-14:56:55.125000000|010|3' *)
IF fbIED.Relay.LLN0.Health.t.sValue <> sValue THEN
    tValue := fbIED.Relay.LLN0.Health.t.tValue;
END_IF 

tValue := String_To_UtcTime('UT#2017-01-16-11:22:33.750000000|001|24');(* ClockNotSynchronized := 1, accuracy := 24 bits *)
sValue := UtcTime_To_String(tValue);(* sValue := 'UT#2017-01-16-11:22:33.750000000|001|24' *)
IF fbIED.Relay.LLN0.Mod_.t.sValue <> sValue THEN
    tValue := fbIED.Relay.LLN0.Mod_.t.tValue;
END_IF 

UtcTime_ToFrom_String := TRUE;