String_To_UtcTime

Converts the UTC-Time information formatted as a string into the components of the structured type T_UtcTime. The string to be converted is specified and 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 String_To_UtcTime : T_UtcTime
VAR_INPUT
    in     : STRING(39) := 'UT#1970-01-01-00:00:00.000000000|000|0';
END_VAR
VAR_OUTPUT
    bError : BOOL;
END_VAR

String_To_UtcTime 1: Inputs

Name

Type

Description

in

STRING(39)

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

String_To_UtcTime 2: Outputs

Name

Type

Description

bError

BOOL

This output is "TRUE" if the input string could not be converted without error.

String_To_UtcTime 3: Return value

Name

Type

Description

String_To_UtcTime

T_UtcTime

Converted time information as UTC-Time structure.

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;