E164 - Implicit conversion between time or date and other types
The types TIME, LTIME, DATE, TIME_OF_DAY, DATE_AND_TIME and their long variants do not convert
implicitly to numbers or to each other. Their values count in a unit that the number does not show.
The warning is reported where such a value is assigned, and at the operand where a comparison, MOD or a
bitwise operation combines a time or date with another type.
Code example:
PROGRAM mainProg
VAR
duration : TIME;
milliseconds : DINT := 1500;
expired : BOOL;
END_VAR
duration := milliseconds; // warning
duration := 5000; // warning
expired := duration > milliseconds; // warning at milliseconds
END_PROGRAM
To silence the warning, use a literal or a conversion function that names the unit:
duration := T#1500ms;
duration := DINT_TO_TIME(milliseconds);
expired := duration > DINT_TO_TIME(milliseconds);
Adding a number to a duration or subtracting one from it is reported by E157. Scaling a duration by a
number, such as duration * 2 or duration / 1.5, converts nothing and is not reported.