String_To_UtcTimeStamp
Converts the UTC timestamp 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: 'US#YYY-MM-DD-hh:mm:ss.nnnnnnn' where:
YYYY:=year
MM:=month
DD:=day
hh:=hour
mm:=minutes
ss:=seconds
nnnnnnn:=nanoseconds (9 decimal places). The T_UtcTime.Quality component is not set during conversion (all bits have the value 0).
Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)
Syntax
FUNCTION String_To_UtcTimeStamp : T_UtcTime
VAR_INPUT
in : STRING(32):='US#1970-01-01-00:00:00.000000000';
END_VAR
VAR_OUTPUT
bError : BOOL;
secondSinceEpoch : DT;
fractionOfSecond : T_UINT24;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
in | STRING(32) | The time information to convert as a formatted UTC timestamp string. |
Outputs
Name | Type | Description |
---|---|---|
bError | BOOL | The output is "TRUE" if the input value could not be converted without error. |
secondSinceEpoch | DT | Value of converted T_UtcTime.secondSinceEpoch component. |
fractionOfSecond | Value of converted T_UtcTime.fractionofSecond component. |
Return value
Name | Type | Description |
---|---|---|
String_To_UtcTimeStamp | Converted timestamp information as UTC time structure. |
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' *)