Tutorial: D2000 and work with time

Image Description

Peter Humaj

August 20 2018, 5 min read

How does time work in D2000? What is its internal representation? Does D2000 support different time zones or summer/winter time? This article attempts to explain some of the trickery of work with time using the lectures of Boris Čonto, who is Head of D2000 department. His lectures entitled "Work with D2000 Time" took place during Friday's workshops.

Basic terms

Coordinated Universal Time (UTC) is a basic time standard based on the International Atomic Time with a leap second, which is applied irregularly to achieve synchronization with the retardant rotation of the Earth.

time1.EN
Figure 1: 9:00 UTC defines the same time in Slovakia as in the USA

As the Earth is round and rotates around the Sun, using UTC time would be impractical. The same time (twelve hours UTC) would mean for some people a noon, for others morning or evening - depending on which part of the world they live in. Therefore, time zones have been adopted.

The time zone is a geographic region that uses the same standard time. The Time zone map does not copy meridians, but it brings in geopolitical influences (see, for example, Russia or China). The time zone around the zero meridian is called Greenwich Mean Time (GMT).

time2.gif
Figure 2: The time zone map

Time offset - parameter of the time zone that defines the time difference between the current time in the time zone and UTC time (usually in whole hours). The GMT time zone has a time offset of 0, the time zone „Central Europe Time (CET)“, in which Slovakia is located, has a 1 hour time offset. The countries eastward of the zero meridian have a positive time offset, the countries westward a negative one.

To determine the time offset, D2000 uses the %GetTimeZone function, which returns the difference in seconds (3600 for CET).

time3.EN
Figure 3: 9:00 UTC corresponds to 10:00 CET

In many countries, in the past they began to shift the time forward in the summer (to better utilize the sunshine hours). The so-called "Summer Time“ was adopted.

Daylight saving time (DST or Summer Time) is the time period within a time zone when a time interval is added to the time offset - usually 1 hour. In Slovakia, summer time begins on the last Sunday of March and ends on the last Sunday in October.

Winter time is the period during which the summer time is not active :)

time4.png
Figure 4: 9:00 UTC corresponds to 10:00 CET (time in Slovakia in winter) or 11:00 CET DST (time in Slovakia in the summer)

Time representation

There are two basic ways to represent the time:

  • A distance from a certain agreed point on the timeline in the agreed time units. In practice, this is usually the number of seconds with a certain accuracy. The agreed start is placed on the UTC timeline (for example, the Unix time is calculated from 1st January 1970 00:00:00 UTC).
  • By expressing its individual components (component time). For such expression of time, it is necessary to know the time zone and the DST.
time5.png
Figure 5: The blue dot represents the start of Unix time (1.1.1972 UTC). The same time point can be expressed as 8:00 UTC or 10:00 UTC+02 (Eastern Europe zone EET).

The transition between Winter and Summer Time

The following figure shows how the change to Daylight Saving Time (DST or Summer Time) and back in the CET timezone works. When switching to Summer Time, the second hour in the morning is omitted (i.e. the second 01:59:59 is followed by 03:00:00). During the transition from Summer to Winter Time, the second hour is inserted twice, i.e. after 01:59:59 follows 02:00:00, 02:00:01 .. etc upto 02:59:59 and then 02:00:00 and again 02:00:01 upto 02:59:59 and then 03:00:00.

time6.EN
Figure 6: The change from Winter to Summer Time (left) and back (right). The red axis indicates the UTC time, the black indicates local time influenced by DST. A2 and B2 notations are used to distinguish "first" and "second" second hours.

Within the EU, the time change takes place at the same time - at 01:00 UTC (i.e., 2:00 CET and 3:00 EET) to jump ahead (Daylight Saving Time) or reverse (winter time). So the difference between CET and GMT as well as between EET and CET is always 1 hour.

In the United States (which include 5 continental time zones + another for the Hawaiian Islands), the change is always at 2 o'clock of local time, so the change of these times is "gradual" and the difference between the bordering time zones is usually 1 hour, but while time is changing this difference is  0 or 2 hours.

Interesting - Australia has three time zones but some countries do not use summer time (Queensland UTC+10, Northern Territory UTC+9:30, Western Australia UTC+8), other do (South Australia UTC+9:30 - UTC+10:30, Tasmania/Victoria/New South Wales UTC+10 - UTC+11). So the result is 3 different times in winter and 5 different times in the summer. Moreover, in (Australian) summer, in South Australia it is 30 minutes later than in Queensland, although it is more westward (and there should be less o‘clock).

How does D2000 deal with the transitions between Summer Time and Winter Time? In the charts, the second hour of the night is omitted or doubled.

time7.png
Figure 7: The graph on the left shows the transition to Summer Time (March, the second hour is missing).On the right is the transition to Winter Time (October, two second hours).

Similarly, the duplication of the second hour can be seen, e.g. in tables of archived values.

time8.EN
Figure 8: Double second hour during the change to winter time. After 2:59 goes again 2:00.

From the point of view of Winter Time -> Summer Time -> Winter Time transitions, the periodic actions are interesting. What does „every eight hours“ mean? When going to Summer Time, is it 0:00, 8:00, 16:00 or 0:00, 9:00, 17:00? What is good?

Continue to the second part of this article

Find an answer to the all questions about working with time in D2000 SCADA programming platform.

Work with time part 2.

Subscription was successful

Thank you for submitting form.

Image Description

Your message was successfully sent.

Thank you for submitting the form.

Image Description

Your message was successfully sent.

Thank you for submitting the form.

Image Description