Applies To:
  • CitectSCADA

Summary:
Using TimeToStr works well for some modes, but does not work as expected for others. For example, using 120 seconds as input, modes 5 ot 8 give me the correct result of 2 minutes. Why does TimeToStr not work for other modes?

Solution:
Modes 5,6,7,and 8 are straight forwards conversion of seconds/milliseconds.
Trying out 120 seconds, and it returns 2 minutes, as expected for modes 5, 7,and 8, and 0.12 seconds for mode 6.

mode 5 - 00:02:00
mode 6 - 000:00:00.120
mode 7 - 00:02
mode 8 - 0 Days 0 Hours 2 min 0 sec

For the other modes, the input must be
-    the number of seconds since since 01/01/1970, and also
-    used with dates from 1980 to 2035.
Using 120 seconds would return times 2 minutes after the start of 1970, but won't work, as it is prior to 1980. TimeToStr will throw a hardware alarm; Invalid argument passed. 315532800 seconds is roughly the smallest you can use; just after midnight GMT on 1/1/1980.

As an example 11-May-09 at 2:44pm, the integer representation is 1,242,017,091 seconds. If you send this into TimeToStr, we get:
mode 0 - 02:44 PM
mode 1 - 02:44:51 PM
mode 2 - 11/05/2009
mode 3 - Monday, 11 May 2009
mode 4 - Mon May 11 2009 02:44:51 PM
mode 9 - 11/05/2009

Keywords:
 TimeToStr cicode

Attachments