1TZSET(3)                   Linux Programmer's Manual                  TZSET(3)
2
3
4

NAME

6       tzset, tzname, timezone, daylight - initialize time conversion informa‐
7       tion
8

SYNOPSIS

10       #include <time.h>
11
12       void tzset (void);
13
14       extern char *tzname[2];
15       extern long timezone;
16       extern int daylight;
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       tzset(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
21       tzname: _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
22       timezone: _SVID_SOURCE || _XOPEN_SOURCE
23       daylight: _SVID_SOURCE || _XOPEN_SOURCE
24

DESCRIPTION

26       The tzset() function initializes the tzname variable from the TZ  envi‐
27       ronment  variable.   This function is automatically called by the other
28       time conversion functions that depend on the timezone.  In a  System-V-
29       like environment, it will also set the variables timezone (seconds West
30       of UTC) and daylight (to 0 if this timezone does not have any  daylight
31       saving  time  rules,  or  to nonzero if there is a time during the year
32       when daylight saving time applies).
33
34       If the TZ variable does not appear in the environment, the tzname vari‐
35       able  is  initialized  with  the best approximation of local wall clock
36       time, as specified by the tzfile(5)-format file localtime found in  the
37       system   timezone   directory   (see  below).   (One  also  often  sees
38       /etc/localtime used here, a symlink to the right  file  in  the  system
39       timezone directory.)
40
41       If  the  TZ  variable  does  appear in the environment but its value is
42       empty or its value cannot be interpreted using any of the formats spec‐
43       ified below, Coordinated Universal Time (UTC) is used.
44
45       The  value of TZ can be one of three formats.  The first format is used
46       when there is no daylight saving time in the local timezone:
47
48              std offset
49
50       The std string specifies the name of the timezone and must be three  or
51       more  alphabetic characters.  The offset string immediately follows std
52       and specifies the time value to be added to the local time to get Coor‐
53       dinated  Universal  Time  (UTC).   The  offset is positive if the local
54       timezone is west of the Prime Meridian and negative if it is east.  The
55       hour must be between 0 and 24, and the minutes and seconds 0 and 59.
56
57       The second format is used when there is daylight saving time:
58
59              std offset dst [offset],start[/time],end[/time]
60
61       There  are  no spaces in the specification.  The initial std and offset
62       specify the standard timezone, as described above.  The dst string  and
63       offset  specify the name and offset for the corresponding daylight sav‐
64       ing timezone.  If the offset is omitted, it default to one  hour  ahead
65       of standard time.
66
67       The  start  field  specifies when daylight saving time goes into effect
68       and the end field specifies when the change is made  back  to  standard
69       time.  These fields may have the following formats:
70
71       Jn     This  specifies  the  Julian day with n between 1 and 365.  Leap
72              days are not counted.  In this format, February 29 can't be rep‐
73              resented; February 28 is day 59, and March 1 is always day 60.
74
75       n      This  specifies  the  zero-based Julian day with n between 0 and
76              365.  February 29 is counted in leap years.
77
78       Mm.w.d This specifies day d (0 <= d <= 6) of week w (1 <= w  <=  5)  of
79              month m (1 <= m <= 12).  Week 1 is the first week in which day d
80              occurs and week 5 is the last week in which day d occurs.  Day 0
81              is a Sunday.
82
83       The  time  fields  specify when, in the local time currently in effect,
84       the change to the other  time  occurs.   If  omitted,  the  default  is
85       02:00:00.
86
87       Here  is  an example for New Zealand, where the standard time (NZST) is
88       12 hours ahead of UTC, and daylight saving time (NZDT), 13 hours  ahead
89       of  UTC,  runs  from the first Sunday in October to the third Sunday in
90       March, and the changeovers happen at the default time of 02:00:00:
91
92           TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0"
93
94       The third format specifies that the timezone information should be read
95       from a file:
96
97              :[filespec]
98
99       If the file specification filespec is omitted, the timezone information
100       is read from the file localtime in the system timezone directory, which
101       nowadays  usually  is  /usr/share/zoneinfo.   This file is in tzfile(5)
102       format.  If filespec is given, it  specifies  another  tzfile(5)-format
103       file to read the timezone information from.  If filespec does not begin
104       with a '/', the file specification is relative to the  system  timezone
105       directory.
106
107       Here's an example, once more for New Zealand:
108
109           TZ=":Pacific/Auckland"
110

FILES

112       The  system  timezone  directory  used  depends on the (g)libc version.
113       Libc4 and libc5 use /usr/lib/zoneinfo, and, since libc-5.4.6, when this
114       doesn't  work, will try /usr/share/zoneinfo.  Glibc2 will use the envi‐
115       ronment variable TZDIR, when that exists.  Its default depends  on  how
116       it was installed, but normally is /usr/share/zoneinfo.
117
118       This timezone directory contains the files
119       localtime      local timezone file
120       posixrules     rules for POSIX-style TZ's
121
122       Often  /etc/localtime is a symlink to the file localtime or to the cor‐
123       rect timezone file in the system timezone directory.
124

CONFORMING TO

126       SVr4, POSIX.1-2001, 4.3BSD.
127

NOTES

129       Note that the variable daylight does not indicate that daylight  saving
130       time  applies  right now.  It used to give the number of some algorithm
131       (see the variable tz_dsttime in gettimeofday(2)).  It has been obsolete
132       for many years but is required by SUSv2.
133
134       4.3BSD  had a function char *timezone(zone, dst) that returned the name
135       of the timezone corresponding to its first argument  (minutes  West  of
136       UTC).  If the second argument was 0, the standard name was used, other‐
137       wise the daylight saving time version.
138

SEE ALSO

140       date(1), gettimeofday(2), time(2), ctime(3), getenv(3), tzfile(5)
141

COLOPHON

143       This page is part of release 3.53 of the Linux  man-pages  project.   A
144       description  of  the project, and information about reporting bugs, can
145       be found at http://www.kernel.org/doc/man-pages/.
146
147
148
149                                  2012-03-25                          TZSET(3)
Impressum