TimeZone (STRUCT)

TYPE TimeZone : STRUCT

To handle the local TIME, it is neccecary to always specify the time and date and the time zone that is currently valid. This makes it possible to convert the local time to Coordinated Universal Time and vice versa. UTC is Coordinated Universal Time. It is a successor to, but distinct from, Greenwich Mean Time (GMT) and the various definitions of Universal Time. UTC is now the worldwide standard for regulating clocks and time measurement. All other timezones are defined relative to UTC, and include offsets like UTC+0800 - hours to add or subtract from UTC to derive the local time. No daylight saving time occurs in UTC, making it a useful timezone to perform date arithmetic without worrying about the confusion and ambiguities caused by daylight saving time transitions, your country changing its timezone, or mobile computers that roam through multiple timezones.

The following snippet exposes the definition of UTC and CentralEuropeTime/CentralEuropeSommerTime.

VAR_GLOBAL CONSTANT
    /// Coordinated Universal Time
    gc_tzTimeZoneUTC : TimeZone := (asgPeriod := [(sName:='UTC')]);

    /// Central Europe Time
    gc_tzTimeZoneCET : TimeZone :=
    (
        iBias := 60 (* T#1M => minutes *),
        asgPeriod := [
        ( (* (CEST -> CET) - Last Sunday in Oktober at 03:00:00.000 (CEST) *)
            sName:='CET',
            dtDate := (uiMonth := 10, eWeekday := WEEKDAY.SUNDAY, uiDay := 5, uiHour := 3)
        ),( (* (CET -> CEST) - Last Sunday in March at 02:00:00.000 (CET) *)
            sName := 'CEST',
            dtDate := (uiMonth := 3, eWeekday := WEEKDAY.SUNDAY, uiDay := 5, uiHour := 2),
            iBias := 60 (* T#1M => minutes *)
        )]
    );
END_VAR
Note

The Bias element represents the offset from the Coordinated Universal Time (UTC). This value is in minutes.

  • The offset growing positive in eastern direction starting from the prime meridian.

  • The offset is growing negative in western direction starting from the prime meridian.

With the data structure TimeZone it is possible to specify every timezone of the world and so the functions can handle the local time conversion and the switching from standard to day light saving period's if necessary.

Example

With the following expressions the difference between the UTC time zone and an other timezone instance can be calculated.

iBiasUTC_Standard := gc_tzTimeZoneCET.iBias;
iBiasUTC_Daylight := gc_tzTimeZoneCET.iBias + gc_tzTimeZoneCET.asgPeriod[PERIOD.DAYLIGHT].iBias;
Note

The time zone which the current computer is configured for, is not always the time zone suitable for displaying the current time. Therefore in the respective application, the possibility should be provided, to be able to select the "correct" time zone that is suitable for the related output option (WebVisu, LogFiles, Email, ...).

InOut:

Name

Type

Comment

iBias

INT

Offset in minutes (local time = UTC + iBias)

asgPeriod

ARRAY [1..2] OF Segment

1 = PERIOD.STANDARD, 2 = PERIOD.DAYLIGHT