Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/tzset.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/tzset.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/tzset.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/tzset.html on line 8

tzset()

Set the time according to the current time zone

Synopsis:

#include <time.h>

void tzset( void );

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The tzset() function sets the global variables daylight, timezone and tzname according to the value of the TZ environment variable, or to the value of the _CS_TIMEZONE configuration string if TZ isn't set.

The global variables have the following values after tzset() is executed:

daylight
Zero indicates that daylight saving time isn't supported in the locale; a nonzero value indicates that daylight saving time is supported in the locale. This variable is cleared or set after a call to the tzset() function, depending on whether or not a daylight saving time abbreviation is specified in the TZenvironment variable.
timezone
The number of seconds that the local time zone is earlier than Coordinated Universal Time (UTC) (formerly known as Greenwich Mean Time (GMT)).
tzname
A two-element array pointing to strings giving the abbreviations for the name of the time zone when standard and daylight saving time are in effect.

The time that you set on the computer with the date command reflects Coordinated Universal Time (UTC). The environment variable TZ is used to establish the local time zone. For more information, see Setting the time zone in the Configuring Your Environment chapter of the Neutrino User's Guide.

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void print_zone()
  {
    char *tz;

    printf( "TZ: %s\n", (tz = getenv( "TZ" ))
            ? tz : "default EST5EDT" );
    printf( "  daylight: %d\n", daylight );
    printf( "  timezone: %ld\n", timezone );
    printf( "  time zone names: %s %s\n",
        tzname[0], tzname[1] );
  }

int main( void )
  {
    tzset();
    print_zone();
    setenv( "TZ", "PST8PDT", 1 );
    tzset();
    print_zone();
    return EXIT_SUCCESS;
  }

produces the output:

TZ: default EST5EDT
  daylight: 1
  timezone: 18000
  time zone names: EST EDT
TZ: PST8PDT
  daylight: 1
  timezone: 28800
  time zone names: PST PDT

Classification:

POSIX 1003.1 XSI

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

ctime(), daylight, localtime(), localtime_r(), mktime(), strftime() timezone, tzname

Setting the time zone in the Configuring Your Environment chapter of the Neutrino User's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/tzset.html on line 198

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/tzset.html on line 198