tzset
Sets value of global variables daylight, timezone, and tzname.
Defined in header <time.h>
Syntax
#include <time.h>
void tzset(void)
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
tzset is available on XENIX systems.
tzset sets the daylight, timezone, and tzname global variables based on the environment variable TZ. The library functions ftlme and localtime use these global variables to correct Greenwich mean time (GMT) to whatever the local time zone is. The format of the TZ environment string follows:
TZ = zzz[+/-]d[d][111]
zzz is a three-character string representing the name of the current time zone. All three characters are required. For example, the string "PST" could be used to represent Pacific Standard Time.
[+/-]rf[d] is a required field containing an optionally signed number with 1 or more digits. This number is the local time zone's difference from GMT in hours. Positive numbers adjust westward from GMT. Negative num-bers adjust eastward from GMT. For example, the number 5 = EST, +8 = PST, and -1 = continental Europe. This number is used in the calculation of the global variable timezone. timezone is the difference in seconds between GMT and the local time zone.
/// is an optional three-character field that represents the local time zone daylight saving time. For example, the string "PDT" could be used to represent Pacific daylight saving time. If this field is present, it will cause the global variable daylight to be set nonzero. If this field is absent, daylight will be set to zero.
If the TZ environment string isn't present or isn't in the preceding form, a default TZ - "EST5EDT" is presumed for the purposes of assigning values to the global variables daylight, timezone, and tzname.
The global variable tzname[0] points to a three-character string with the value of the time-zone name from the TZ environment string. tzname[l] points to a three-character string with the value of the daylight saving time-zone name from the TZ environment string. If no daylight saving name is present, tzname[l] points to a null string.
Return value
None.
See also
Example
#include <time.h>
#include <stdlib.h>
*include <stdio.h>
int main (void)
{
time_t td;
putenv("TZ=PST8PDT") ;
tzset ();
time(&td);
printf {"Current time = %s\n", asctime (locaitime(&td)
return
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/time.h/tzset/
· short form /3.1/tzset/