Sets and accesses time-zone conversion.
#include <time.h> void tzset (void); extern char *tzname[]; extern long int timezone; extern int daylight;
This function initializes time conversion information used by the ctime, localtime, mktime, strftime, and wcsftime functions.
The tzset function sets the following external variables:
tzname[0] = "std" tzname[1] = "dst"
The environment variable TZ specifies how tzset initializes time conversion information:
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:
Uppercase and lowercase letters are explicitly allowed. Any characters are allowed, except the following:
| |
offset-The
value added to the local time to arrive at UTC. The offset has the
following format:
hh[:mm[:ss]] In this format:
| |
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:
| |
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:
| |
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.
EST5EDT4,M4.1.0,M10.5.0This 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.