Applies To:
  • CitectSCADA

 We require the need to adjust our System time, as our System is on a ship, which travels across multiple timezones, we used to use TimeSet, but it has been deprecated in our version of Citect.

 Even though Timset functionality is being re-introduced into Citect, you should NOT use it in this manner. Timeset() adjusts the UTC time on the PC. This is suitable if you want to synchronise the time on your PC by a few seconds, however, you should not change the UTC system time in order to compensate for different timezones, you should change the GMT offset that the PC is using when displaying the time, i.e change the TimeZone.

The reason for this is, for example, Trend Data is stored in UTC format, and is automatically displayed in the Client's local Timezone.
If the Timezone of a PC (GMT offset) is changed, then the data display will automatically adjust, without changing the stored trend data.

However, if the UTC time is changed, as it is with TimeSet(), then this affects the stored Trend Data.

i.e say we wind the clock back 1 hr (via TimeSet() or manually), then the last hour of Trend Data, stored in UTC time, will be overwritten with new data. Conversely, if the UTC time is wound forward, then you will have a 1hr gap in your Trends.

The correct way would be to leave the UTC time un-modified, and instead select the correct timezone in Windows. This can be done purely in Cicode, the attachment contains the full Cicode, tested on Windows XP.

To summarise the Cicode, we have a string array, containing all the available TimeZones that Windows XP has available, and we execute a command-line function to change to that TimeZone. I have created functions so that the TimeZone can be referenced by Name, or by its index in our Array. There is also a function to select and apply the new Timezone from a Cicode form:

In Terms of Windows privileges, you need to be an Admin, or Power User by default, otherwise you can adjust your windows security settings according to:

ChangeTimezoneByNumber(2); // Changes Timezone to "(GMT-10:00) Hawaii"
ChangeTimezoneByName("(GMT-10:00) Hawaii"); // Changes Timezone to "(GMT-10:00) Hawaii"
ChangeTimezoneForm(); //Then Select Timezone from Drop-down list, and click 'APPLY'

Cicode Definition:
STRING gsaTimeZone[90]= "(GMT-12:00) International Date Line West" // 0
   ,"(GMT-11:00) Midway Island, Samoa" // 1
   ,"(GMT-10:00) Hawaii" // 2
   ,"(GMT-09:00) Alaska" // 3
   ,"(GMT+12:00) Fiji, Kamchatka, Marshall Is." // 88
   ,"(GMT+13:00) Nuku'alofa" // 89
   //These are the Windows XP Formats

INT FUNCTION ChangeTimezoneByNumber(INT NewZone)
 IF NewZone < 89 AND NewZone >= 0 THEN
  Exec("cmd /c ^"Rundll32.exe shell32.dll,Control_RunDLL %SystemRoot%\System32\TIMEDATE.cpl,,/Z" + gsaTimeZone[NewZone] + "^"",6)

INT FUNCTION ChangeTimezoneByName(STRING sNewZone)
 Exec("cmd /c ^"Rundll32.exe shell32.dll,Control_RunDLL %SystemRoot%\System32\TIMEDATE.cpl,,/Z" + sNewZone + "^"",6)

FUNCTION ChangeTimezoneForm()
 INT i;
 FormNew("Change Timezone",55,1,0)
 FormComboBox(0 ,0, 35, 10, sBuf, 1);
 FOR i = 0 TO 89 DO
 FormButton(35 ,0 ,"  APPLY  ", 0, 1);
 FormButton(46 ,0 ," CANCEL ", 0, 2);
 IF FormRead(0) = 0 THEN
  Message("Timezone Changed","TimeZone Changed to: " + sBuf,0)

By: Warwick Black

 Time Timezone zone cicode timeset