tzset

Sets and accesses time-zone conversion.

Format

#include  <time.h>

void tzset  (void);

extern  char *tzname[];

extern  long int timezone;

extern  int daylight;

Description

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

The tzset function sets the following external variables:

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

Table 13 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[dst[offset] [,rule]]   The value is first used as the pathname of a file (as described for the :pathname format) from which 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:

  • std-Standard time zone. Required.

  • 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:

  • digits

  • leading colon (:)

  • comma (,)

  • minus (-)

  • plus (+)

  • 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:

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

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

  • 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:

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

  • end is the date for returning from summer time to standard time.
 
  If start and end are omitted, the default is the US Daylight Saving Time start and end dates. The format for start and end must be one of the following:

  • 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.

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

  • 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 system logical SYS$POSIXRULES 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.  

[1] The DEC C RTL uses a public-domain, time-zone handling package that puts time-zone conversion rules in easily accessible and modifiable files. These files reside in the directory SYS$COMMON:[SYS$ZONEINFO.SYSTEM.SOURCES].

The time-zone compiler zic converts these files to a special format described by the <tzfile.h> header file. The converted files are created with a root directory of SYS$COMMON:[SYS$ZONEINFO.SYSTEM], which is pointed to by the SYS$TZDIR system logical. This format is readable by the C library functions that handle time-zone information. For example, in the eastern United Stated, SYS$LOCALTIME is defined to be SYS$COMMON:[SYS$ZONEINFO.SYSTEM.US]EASTERN.

See also ctime, localtime, mktime, strftime, and wcsftime in this section.

Sample TZ Specification

  1. 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:

    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.


Previous Page | Next Page | Table of Contents | Index