1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sun Jul 25 11:01:58 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 2001-11-13, aeb
29 .\" Modified 2004-12-01 mtk and Martin Schulze <joey@infodrom.org>
31 .TH TZSET 3 2010-02-25 "" "Linux Programmer's Manual"
33 tzset, tzname, timezone, daylight \- initialize time conversion information
40 .BI "extern char *" tzname [2];
41 .BI "extern long " timezone ;
42 .BI "extern int " daylight ;
46 Feature Test Macro Requirements for glibc (see
47 .BR feature_test_macros (7)):
51 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
54 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
57 _SVID_SOURCE || _XOPEN_SOURCE
60 _SVID_SOURCE || _XOPEN_SOURCE
64 function initializes the \fItzname\fP variable from the
67 This function is automatically called by the
68 other time conversion functions that depend on the timezone.
69 In a System-V-like environment, it will also set the variables \fItimezone\fP
70 (seconds West of UTC) and \fIdaylight\fP (to 0 if this timezone does not
71 have any daylight saving time rules, or to nonzero if there is a time during
72 the year when daylight saving time applies).
76 variable does not appear in the environment, the \fItzname\fP
77 variable is initialized with the best approximation of local wall clock
78 time, as specified by the
81 found in the system timezone directory (see below).
84 used here, a symlink to the right file in the system timezone directory.)
88 variable does appear in the environment but its value is empty
89 or its value cannot be interpreted using any of the formats specified
90 below, Coordinated Universal Time (UTC) is used.
94 can be one of three formats.
95 The first format is used
96 when there is no daylight saving time in the local timezone:
102 The \fIstd\fP string specifies the name of the timezone and must be
103 three or more alphabetic characters.
104 The \fIoffset\fP string immediately
105 follows \fIstd\fP and specifies the time value to be added to the local
106 time to get Coordinated Universal Time (UTC).
107 The \fIoffset\fP is positive
108 if the local timezone is west of the Prime Meridian and negative if it is
110 The hour must be between 0 and 24, and the minutes and seconds
113 The second format is used when there is daylight saving time:
116 .I std offset dst [offset],start[/time],end[/time]
119 There are no spaces in the specification.
120 The initial \fIstd\fP and
121 \fIoffset\fP specify the standard timezone, as described above.
122 The \fIdst\fP string and \fIoffset\fP specify the name and offset for the
123 corresponding daylight saving timezone.
124 If the offset is omitted,
125 it default to one hour ahead of standard time.
127 The \fIstart\fP field specifies when daylight saving time goes into
128 effect and the \fIend\fP field specifies when the change is made back to
130 These fields may have the following formats:
133 This specifies the Julian day with \fIn\fP between 1 and 365.
134 February 29 is never counted even in leap years.
137 This specifies the Julian day with \fIn\fP between 1 and 365.
138 February 29 is counted in leap years.
140 M\fIm\fP.\fIw\fP.\fId\fP
141 This specifies day \fId\fP (0 <= \fId\fP <= 6) of week \fIw\fP
142 (1 <= \fIw\fP <= 5) of month \fIm\fP (1 <= \fIm\fP <= 12).
144 the first week in which day \fId\fP occurs and week 5 is the last week
145 in which day \fId\fP occurs.
148 The \fItime\fP fields specify when, in the local time currently in effect,
149 the change to the other time occurs.
150 If omitted, the default is 02:00:00.
152 Here is an example for New Zealand,
153 where the standard time (NZST) is 12 hours ahead of UTC,
154 and daylight saving time (NZDT), 13 hours ahead of UTC,
155 runs from the first Sunday in October to the third Sunday in March,
156 and the changeovers happen at the default time of 02:00:00:
159 TZ="NZST-12.00:00NZDT-13:00:00,M10.1.0,M3.3.0"
162 The third format specifies that the timezone information should be read
169 If the file specification \fIfilespec\fP is omitted, the timezone
170 information is read from the file
172 in the system timezone directory, which nowadays usually is
173 .IR /usr/share/zoneinfo .
177 If \fIfilespec\fP is given, it specifies another
178 .BR tzfile (5)-format
179 file to read the timezone information from.
180 If \fIfilespec\fP does not begin with a \(aq/\(aq, the file specification is
181 relative to the system timezone directory.
183 Here's an example, once more for New Zealand:
186 TZ=":Pacific/Auckland"
189 The system timezone directory used depends on the (g)libc version.
191 .IR /usr/lib/zoneinfo ,
192 and, since libc-5.4.6,
193 when this doesn't work, will try
194 .IR /usr/share/zoneinfo .
195 Glibc2 will use the environment variable
198 Its default depends on how it was installed, but normally is
199 .IR /usr/share/zoneinfo .
201 This timezone directory contains the files
203 localtime local timezone file
204 posixrules rules for POSIX-style TZ's
209 is a symlink to the file
211 or to the correct timezone file in the system timezone directory.
213 SVr4, POSIX.1-2001, 4.3BSD.
215 Note that the variable \fIdaylight\fP does not indicate that daylight
216 saving time applies right now.
217 It used to give the number of some
218 algorithm (see the variable \fItz_dsttime\fP in
219 .BR gettimeofday (2)).
220 It has been obsolete for many years but is required by SUSv2.
222 4.3BSD had a function
223 .BI "char *timezone(" zone ", " dst )
225 name of the timezone corresponding to its first argument (minutes
227 If the second argument was 0, the standard name was used,
228 otherwise the daylight saving time version.
231 .BR gettimeofday (2),