BinaryTime6Day_To_Date

Converts the number of days since January 1, 1984 from type WORD to a date of type DATE. The function returns the max. representable DATE value "D#2106-02-07" if the day to be converted is greater than the value "16#AE35".

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

Syntax

FUNCTION BinaryTime6Day_To_Date : DATE
VAR_INPUT
    in     : WORD(0..16#AE35);
END_VAR
VAR_OUTPUT
    bError : BOOL;
END_VAR

BinaryTime6Day_To_Date 1: Inputs

Name

Type

Description

in

WORD(0..16#AE35)

The number of days since January 1, 1984 to be converted. This value corresponds to the value of the T_BinaryTime.day component.

BinaryTime6Day_To_Date 2: Outputs

Name

Type

Description

bError

BOOL

The output is "TRUE" if the input value is greater than "16#AE35" (February 7, 2106). In this case the function returns the value "D#1970-01-01".

BinaryTime6Day_To_Date 3: Return value

Name

Type

Description

BinaryTime6Day_To_Date

DATE

Date in the DATE format.

Sample

METHOD FINAL BinaryTime6Day_ToFrom_Date : BOOL
VAR
    tValue : T_BinaryTime;
    d      : DATE;
    sValue : STRING;
END_VAR

tValue.timeOfDay:=TOD#00:00:00.125;
tValue.day:=Date_To_BinaryTime6Day(D#1984-01-01);(* tValue.day:=16#0000 *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#1984-01-01-00:00:00.125' *) 
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#1984-01-01 *)

tValue.timeOfDay:=TOD#01:02:03.125;
tValue.day:=Date_To_BinaryTime6Day(D#1984-01-02);(* tValue.day:=16#0001 *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#1984-01-02-01:02:03.125' *)
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#1984-01-02 *)

tValue.timeOfDay:=TOD#04:05:06.125;
tValue.day:=Date_To_BinaryTime6Day(D#2018-03-21);(* tValue.day:=16#30D2 *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#2018-03-21-04:05:06.125' *)
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#2018-03-21 *)

tValue.timeOfDay:=TOD#07:08:09;
tValue.day:=tValue.day + 7;(* add 7 days *)
sValue:=BinaryTime6_To_String(tValue);(* sValue:='BT#2018-03-28-07:08:09' *)
d:=BinaryTime6Day_To_Date(tValue.day);(* d:=D#2018-03-28 *)

BinaryTime6Day_ToFrom_Date:=TRUE;