UtcTimeStamp_To_String

Converts the components of the structured type T_UtcTime into a formatted UTC timestamp string. The resulting string has the following structure: 'US#YYY-MM-DD-hh:mm:ss.nnnnnnn':
YYYY:=year
MM:=month
DD:=day
hh:=hour
mm:=minutes
ss:=seconds
nnnnnnn:=nanoseconds (9 decimal places).
The T_UtcTime.Quality component is not converted to the string.

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

Syntax

FUNCTION UtcTimeStamp_To_String : STRING(32)
VAR_INPUT
    in     : T_UtcTime;
END_VAR
VAR_OUTPUT
    bError : BOOL;
END_VAR

UtcTimeStamp_To_String 1: Inputs

Name

Type

Description

in

T_UtcTime

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

UtcTimeStamp_To_String 2: Outputs

Name

Type

Description

bError

BOOL

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

UtcTimeStamp_To_String 3: Return value

Name

Type

Description

UtcTimeStamp_To_String

STRING(32)

Converted time information as a formatted UTC timestamp string.

Sample

PROGRAM MAIN
VAR
    tUtc             : T_UtcTime;
    sUtc             : STRING;
    bError           : BOOL;
    secondSinceEpoch : DT;
    fractionOfSecond : T_UINT24;
END_VAR
tUtc:=String_To_UtcTimeStamp(in:='US#2022-09-15-16:12:34.750000000' , bError=>bError, secondSinceEpoch=>secondSinceEpoch, fractionOfSecond=>fractionOfSecond);
sUtc:=UtcTimeStamp_To_String(in:=tUtc, bError=>bError);(* => sUtc = 'US#2022-09-15-16:12:34.750000000' *)

tUtc.secondSinceEpoch:=DT#2022-09-15-00:00:00;
tUtc.fractionOfSecond[0]:=0;
tUtc.fractionOfSecond[1]:=0;
tUtc.fractionOfSecond[2]:=0;
sUtc:=UtcTimeStamp_To_String(in:=tUtc, bError=>bError);(* => sUtc ='US#2022-09-15-00:00:00.000000000' *)