VMS Help  —  CRTL  tzset
    Sets and accesses time-zone conversion.

    Format

      #include  <time.h>

      void tzset  (void);

      extern  char *tzname[];

      extern  long int timezone;

      extern  int daylight;

1  –  Description

    The tzset function initializes time-conversion information
    used by the ctime, localtime, mktime, strftime, and wcsftime
    functions.

    The tzset function sets the following external variables:

    o  tzname is set as follows, where "std" is a 3-byte name for
       the standard time zone, and "dst" is a 3-byte name for the
       Daylight Savings Time zone:

       tzname[0] = "std"
       tzname[1] = "dst"

    o  daylight is set to 0 if Daylight Savings Time should never be
       applied to the time zone. Otherwise, daylight is set to 1.

    o  timezone is set to the difference between UTC and local
       standard time.

    The environment variable TZ specifies how tzset initializes time
    conversion information:

    o  If TZ is absent from the environment, the implementation-
       dependent time-zone information is used, as follows:

          The best available approximation to local wall-clock time
          is used, as defined by the SYS$LOCALTIME system logical,
          which points to a tzfile format file that describes default
          time-zone rules.
          This system logical is set during the installation
          of OpenVMS Version 7.0 or higher to define a
          time-zone file based off the root directory
          SYS$COMMON:[SYS$ZONEINFO.SYSTEM].

    o  If TZ appears in the environment but its value is a null
       string, Coordinated Universal Time (UTC) is used (without
       leap-second correction).

    o  If TZ appears in the environment and its value is not a null
       string, the value has one of three formats, as described in
       Time-Zone Initialization Rules.

    Table REF-11 Time-Zone Initialization Rules

    TZ Format    Meaning

    :            UTC is used.
    :pathname    The characters following the colon specify the
                 pathname of a tzfile format file from which to
                 read the time-conversion information. A pathname
                 beginning with a slash (/)  represents an absolute
                 pathname; otherwise, the pathname is relative to
                 the system time-conversion information directory
                 specified by SYS$TZDIR, which by default is
                 SYS$COMMON:[SYS$ZONEINFO.SYSTEM].
    stdoffset[dstThefset]e is first used as the pathname of a file
                 (as described for the :pathname format) from which
    [,rule]]     to read the time-conversion information.

                 If that file cannot be read, the value is then
                 interpreted as a direct specification of the time-
                 conversion information, as follows:
                 std and dst-Three or more characters that are the
                 designation for the time zone:

                 o  std-Standard time zone. Required.

                 o  dst-Daylight Savings Time zone. Optional. If dst
                    is omitted, Daylight Savings Time does not apply.

                 Uppercase and lowercase letters are explicitly
                 allowed. Any characters are allowed, except the
                 following:

                 o  digits

                 o  leading colon (:)

                 o  comma (,)

                 o  minus (-)

                 o  plus (+)

                 o  ASCII null character

                 offset-The value added to the local time to arrive
                 at UTC. The offset has the following format:

                 hh[:mm[:ss]]

                 In this format:

                 o  hh (hours) is a one-or two-digit value of 0-24.

                 o  mm (minutes) is a value of 0-59. (optional)

                 o  ss (seconds) is a value of 0-59. (optional)

                 The offset following std is required. If no offset
                 follows dst, summer time is assumed, one hour ahead
                 of standard time. You can use one or more digits;
                 the value is always interpreted as a decimal number.

                 If the time zone is preceded by a minus sign (-),
                 the time zone is East of Greenwich; otherwise, it
                 is West, which can also be indicated by a preceding
                 plus sign (+).
                 rule-Indicates when to change to and return from
                 summer time. The rule has the form:

                 start[/time], end[/time]

                 where:

                 o  start is the date when the change from standard
                    time to summer time occurs.

                 o  end is the date for returning from summer time to
                    standard time.

                 If start and end are omitted, the default is the
                 US Daylight Savings Time start and end dates.
                 The format for start and end must be one of the
                 following:

                 o  Jn-The Julian day n (1 < n < 365). Leap days are
                    not counted. That is, in all years, including
                    leap years, February 28 is day 59 and March 1 is
                    day 60. You cannot explicitly refer to February
                    29.

                 o  n-The zero based Julian day (0 < n < 365). Leap
                    days are counted, making it possible to refer to
                    February 29.

                 o  Mm.n.d-The nth d day of month m, where:

                       0 < n < 5
                       0 < d < 6
                       1 < m < 12

                    When n is 5, it refers to the last d day of month
                    m. Sunday is day 0.

                 time-The time when, in current time, the change to
                 or return from summer time occurs. The time argument
                 has the same format as offset, except that you
                 cannot use a leading minus (-)  or plus (+) sign.
                 If time is not specified, the default is 02:00:00.

                 If no rule is present in the TZ specification, the
                 rules used are those specified by the tzfile format
                 file defined by the SYS$POSIXRULES system logical
                 in the system time-conversion information directory,
                 with the standard and summer time offsets from UTC
                 replaced by those specified by the offset values in
                 TZ.

                 If TZ does not specify a tzfile format file and
                 cannot be interpreted as a direct specification, UTC
                 is used.

                                   NOTE

       The UTC-based time functions, introduced in OpenVMS Version
       7.0, had degraded performance compared with the non-UTC-
       based time functions.

       OpenVMS Version 7.1 added a cache for time-zone files to
       improve performance. The size of the cache is determined
       by the logical name DECC$TZ_CACHE_SIZE. To accommodate most
       countries changing the time twice per year, the default
       cache size is large enough to hold two time-zone files.

    See also ctime, localtime, mktime, strftime, and wcsftime.

2  –  Sample TZ Specification

        EST5EDT4,M4.1.0,M10.5.0

      This sample TZ specification describes the rule defined in 1987
      for the Eastern time zone in the US:

      o  EST (Eastern Standard Time) is the designation for standard
         time, which is 5 hours behind UTC.

      o  EDT (Eastern Daylight Time) is the designation for summer
         time, which is 4 hours behind UTC. EDT starts on the first
         Sunday in April and ends on the last Sunday in October.

      Because time was not specified in either case, the changes
      occur at the default time, which is 2:00 A.M. The start and
      end dates did not need to be specified, because they are the
      defaults.
Close Help