Skip to main content

     
  TPF : Library : TPF Newsletters
  Products   >   Software   >   Transaction Systems   >   TPF   >   Library   >   TPF System Newsletters   >  
 

The Time Zone (TZ) Environment Variable

Carmel V. Khanna, IBM TPF Development

With APAR PJ29957 , TPF system supports TZ environment variable, which is used to customize time zone information on POSIX systems. The default time zone name on the TPF system is local standard time (LST). LST uses the system time to determine the offset from Coordinated Universal Time (UTC), which is also referred to as Greenwich Mean Time (GMT). The TPF system time zone difference (the difference between local standard time and Greenwich Mean Time) is defined in keypoint record A (CTKA). TPF converts this value to hexadecimal and stores it in the CK1LGD field of macro CK1KE (keypoint A).

Question: How can the time zone information be customized?

Answer: The time zone information can be customized by using the TZ environment variable. If the TZ environment variable is not used, the time zone information is set by the LC_TOD category of the current locale. If the setlocale() function is not called, the current locale is the default locale that is built into the C support library. The LC_TOD category is an IBM extension to specify time zone information and a nonstandard locale category.

Question: Who can use the contents of the TZ environment variable?

Answer: The contents of the TZ environment variable are used by the ctime(), localtime(), strftime(), and mktime() functions, and by various utilities to override the default time zone.

Question: What is the format in which the value of the TZ variable can be defined?

Answer: The format in which the value of the TZ variable can be defined is:

std offset dst [offset],start[/time],end[/time]

You can use this format to specify time zones that observe Daylight Saving Time and those that do not observe Daylight Saving Time.

  • std specifies the time zone name and offsetspecifies the time value that you must add to the local time to get Coordinated Universal Time (UTC). It has the following syntax: [+|-]hh[:mm[:ss]]. The time value is negative if the local time zone is east of the Prime Meridian and positive if it is west. The minutes (mm) and seconds (ss) are optional. The hour (hh) is required.
  • dst and offset specify the corresponding Daylight Saving Time zone. If offset is omitted, the default is 1 hour.
  • start[/time] and end[/time] specify when Daylight Saving Time begins and when it ends. If time is omitted, the default is 02:00:00.

For example, this is how we would specify the Eastern time zone using the previous format, observing Daylight Saving Time:

EST+5EDT,M4.1.0/2,M10.5.0/2

In the previous example, the following information is specified:

  • The time zone name for the Eastern time zone in the United States is EST, which is 5 hours behind Coordinated Universal Time (UTC). The time value is positive because it is west of the Prime Meridian.
  • The time zone name for Daylight Saving Time (DST) is EDT and the date in which it starts is the first Sunday in April at 2:00 a.m. The date that EDT ends is the last Sunday in October at 2:00 a.m.
  • The DST offset defaults to 1 hour if omitted. The offset following the local standard time zone (5) specifies the time value that you must add to the local time to get a UTC value.

The following is an example that specifies the Western European time zone without observing the Daylight Saving Time using the previous format:

WEST-1

In the previous example, the following information is specified:

  • The time zone name for the Western European time zone is WEST, which is 1 hour ahead of Coordinated Universal Time (UTC). The time value is negative because it is east of the Prime Meridian.

Question: How does the TZ environment variable get set?

Answer: The TZ environment variable is set by calling the setenv function; for example:

setenv("TZ","EST+5EDT,M4.1.0/2,M10.5.0/2",1) setenv("TZ", "WEST-1",1)