Time Zone State (The GNU C Library)

#### 22.5.7 State Variables for Time Zones ¶

For compatibility with POSIX, the GNU C Library defines global state variables that depend on time zone rules specified by the `TZ` environment variable. However, these state variables are obsolescent and are planned to be removed in a future version of POSIX, and programs generally should avoid them because they are not thread-safe and their values are specified only when `TZ` uses the proleptic format. See Specifying the Time Zone with `TZ`. Programs should instead use the `tm_gmtoff` and `tm_zone` members of `struct tm`. See Broken-down Time.

Function: `void` tzset `(void)` ¶

  Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe lock mem fd | See POSIX Safety Concepts.

  The `tzset` function initializes the state variables from the value of the `TZ` environment variable. It is not usually necessary for your program to call this function, partly because your program should not use the state variables, and partly because this function is called automatically when you use the time conversion functions `localtime`, `mktime`, `strftime`, `strftime_l`, and `wcsftime`, or the deprecated function `ctime`. Behavior is undefined if one thread accesses any of these variables directly while another thread is calling `tzset` or any other function that is required or allowed to behave as if it called `tzset`.

Variable: `char *` tzname `[2]` ¶

  The array `tzname` contains two strings, which are abbreviations of time zones (standard and Daylight Saving) that the user has selected. `tzname[0]` abbreviates a standard time zone (for example, `"EST"`), and `tzname[1]` abbreviates a time zone when daylight saving time is in use (for example, `"EDT"`). These correspond to the std and dst strings (respectively) when the `TZ` environment variable uses the proleptic format. The string values are unspecified if `TZ` uses the geographical format, so it is generally better to use the broken-down time structure’s `tm_zone` member instead.

  In the GNU C Library, the strings have a storage lifetime that lasts indefinitely; on some other platforms, the lifetime lasts only until `TZ` is changed.

  The `tzname` array is initialized by `tzset`. Though the strings are declared as `char *` the user must refrain from modifying them. Modifying the strings will almost certainly lead to trouble.

Variable: `long int` timezone ¶

  This contains the difference between UTC and local standard time, in seconds west of the Prime Meridian. For example, in the U.S. Eastern time zone, the value is `5*60*60`. Unlike the `tm_gmtoff` member of the broken-down time structure, this value is not adjusted for daylight saving, and its sign is reversed. The value is unspecified if `TZ` uses the geographical format, so it is generally better to use the broken-down time structure’s `tm_gmtoff` member instead.

Variable: `int` daylight ¶

  This variable is nonzero if daylight saving time rules apply. A nonzero value does not necessarily mean that daylight saving time is now in effect; it means only that daylight saving time is sometimes in effect. This variable has little or no practical use; it is present for POSIX compatibility.