RAD Studio
ContentsIndex
PreviousUpNext
_tzset, _wtzset

Header File 

time.h  

Category 

Time and Date Routines 

Prototype 

void _tzset(void) 

void _wtzset(void) 

Description 

Sets value of global variables _daylight, _timezone, and _tzname. 

_tzset is available on XENIX systems. 

_tzset sets the _daylight, _timezone, and _tzname global variables based on the environment variable TZ. _wtzset sets the _daylight, _timezone, and _wtzname global variables. The library functions ftime and localtime use these global variables to adjust Greenwich Mean Time (GMT) to the local time zone. The format of the TZ environment string is: 

TZ = zzz[+/-]d[d][lll] 

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

[+/-]d[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 numbers 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. 

lll 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 causes the global variable _daylight to be set nonzero. If this field is absent, _daylight is 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. On a Win32 system, none of these global variables are set if TZ is null. 

The global variables _tzname[0] and _wtzname[1] point to a three-character string with the value of the time-zone name from the TZ environment string. _tzname[1] and _wtzname[1] point 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[1] and _wtzname[1] point to a null string. 

Return Value 

None. 

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(localtime(&td)));
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
_tzset 
 
 
_wtzset 
 
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!