Applies To: |
|
Summary: |
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. |
Solution: |
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: http://support.microsoft.com/kb/300022 Usage: ChangeTimezoneByNumber(2); // Changes Timezone to "(GMT-10:00) Hawaii" or ChangeTimezoneByName("(GMT-10:00) Hawaii"); // Changes Timezone to "(GMT-10:00) Hawaii" or 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 ... //FULL ARRAY IS IN ATTACHED CICODE FILE ,"(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) INT FUNCTION ChangeTimezoneByName(STRING sNewZone) FUNCTION ChangeTimezoneForm() By: Warwick Black |
Keywords: |
Time Timezone zone cicode timeset |
Related Links