]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/tzset.3
getauxval.3: wfix
[thirdparty/man-pages.git] / man3 / tzset.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\" 386BSD man pages
29 .\" Modified Sun Jul 25 11:01:58 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified 2001-11-13, aeb
31 .\" Modified 2004-12-01 mtk and Martin Schulze <joey@infodrom.org>
32 .\"
33 .TH TZSET 3 2015-08-08 "" "Linux Programmer's Manual"
34 .SH NAME
35 tzset, tzname, timezone, daylight \- initialize time conversion information
36 .SH SYNOPSIS
37 .nf
38 .B #include <time.h>
39 .sp
40 .B void tzset (void);
41 .sp
42 .BI "extern char *" tzname [2];
43 .BI "extern long " timezone ;
44 .BI "extern int " daylight ;
45 .fi
46 .sp
47 .in -4n
48 Feature Test Macro Requirements for glibc (see
49 .BR feature_test_macros (7)):
50 .in
51 .sp
52 .BR tzset ():
53 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
54 .br
55 .IR tzname :
56 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
57 .br
58 .IR timezone :
59 _SVID_SOURCE || _XOPEN_SOURCE
60 .br
61 .IR daylight :
62 _SVID_SOURCE || _XOPEN_SOURCE
63 .SH DESCRIPTION
64 The
65 .BR tzset ()
66 function initializes the \fItzname\fP variable from the
67 .B TZ
68 environment variable.
69 This function is automatically called by the
70 other time conversion functions that depend on the timezone.
71 In a System-V-like environment, it will also set the variables \fItimezone\fP
72 (seconds West of UTC) and \fIdaylight\fP (to 0 if this timezone does not
73 have any daylight saving time rules, or to nonzero if there is a time during
74 the year when daylight saving time applies).
75 .PP
76 If the
77 .B TZ
78 variable does not appear in the environment, the system timezone is used.
79 The system timezone is configured by copying, or linking, a file in the
80 .BR tzfile "(5) format to"
81 .IR /etc/localtime .
82 A timezone database of these files may be located in the system
83 timezone directory (see the \fBFILES\fP section below).
84 .PP
85 If the
86 .B TZ
87 variable does appear in the environment, but its value is empty,
88 or its value cannot be interpreted using any of the formats specified
89 below, then Coordinated Universal Time (UTC) is used.
90 .PP
91 The value of
92 .B TZ
93 can be one of two formats.
94 The first format is a string of characters that directly represent the
95 timezone to be used:
96 .sp
97 .RS
98 .IR "std offset" [ dst [ offset ][, start [ /time ], end [ /time ]]]
99 .RE
100 .sp
101 There are no spaces in the specification.
102 The \fIstd\fP string specifies an abbreviation for the timezone and must be
103 three or more alphabetic characters.
104 When enclosed between the less-than (<) and greater-than (>) signs, the
105 characters set is expanded to include the plus (+) sign, the minus (-)
106 sign, and digits.
107 The \fIoffset\fP string immediately
108 follows \fIstd\fP and specifies the time value to be added to the local
109 time to get Coordinated Universal Time (UTC).
110 The \fIoffset\fP is positive
111 if the local timezone is west of the Prime Meridian and negative if it is
112 east.
113 The hour must be between 0 and 24, and the minutes and seconds 00 and 59:
114 .sp
115 .RS
116 .RI [ + | - ] hh [ :mm [ :ss ]]
117 .RE
118 .sp
119 .PP
120 The \fIdst\fP string and \fIoffset\fP specify the name and offset for the
121 corresponding daylight saving timezone.
122 If the offset is omitted,
123 it defaults to one hour ahead of standard time.
124 .PP
125 The \fIstart\fP field specifies when daylight saving time goes into
126 effect and the \fIend\fP field specifies when the change is made back to
127 standard time.
128 These fields may have the following formats:
129 .TP
130 J\fIn\fP
131 This specifies the Julian day with \fIn\fP between 1 and 365.
132 Leap days are not counted.
133 In this format, February 29 can't be represented;
134 February 28 is day 59, and March 1 is always day 60.
135 .TP
136 .I n
137 This specifies the zero-based Julian day with \fIn\fP between 0 and 365.
138 February 29 is counted in leap years.
139 .TP
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).
143 Week 1 is
144 the first week in which day \fId\fP occurs and week 5 is the last week
145 in which day \fId\fP occurs.
146 Day 0 is a Sunday.
147 .PP
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.
151
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:
157 .nf
158
159 TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0"
160 .fi
161 .PP
162 The second format specifies that the timezone information should be read
163 from a file:
164 .sp
165 .RS
166 :[filespec]
167 .RE
168 .sp
169 If the file specification \fIfilespec\fP is omitted, or its value cannot
170 be interpreted, then Coordinated Universal Time (UTC) is used.
171 If \fIfilespec\fP is given, it specifies another
172 .BR tzfile (5)-format
173 file to read the timezone information from.
174 If \fIfilespec\fP does not begin with a \(aq/\(aq, the file specification is
175 relative to the system timezone directory.
176 If the colon is omitted each
177 of the above \fBTZ\fP formats will be tried.
178 .PP
179 Here's an example, once more for New Zealand:
180 .nf
181
182 TZ=":Pacific/Auckland"
183 .fi
184 .SH ENVIRONMENT
185 .TP
186 .B TZ
187 If this variable is set its value takes precedence over the system
188 configured timezone.
189 .TP
190 .B TZDIR
191 If this variable is set its value takes precedence over the system
192 configured timezone database directory path.
193 .SH FILES
194 .TP
195 .I /etc/localtime
196 The system timezone file.
197 .TP
198 .I /usr/share/zoneinfo/
199 The system timezone database directory.
200 .TP
201 .I /usr/share/zoneinfo/posixrules
202 When a TZ string includes a dst timezone without anything following it,
203 then this file is used for the start/end rules.
204 It is in the
205 .BR tzfile "(5) format."
206 By default, the zoneinfo Makefile hard links it to the
207 .IR America/New_York " tzfile."
208 .PP
209 Above are the current standard file locations, but they are
210 configurable when glibc is compiled.
211 .SH ATTRIBUTES
212 For an explanation of the terms used in this section, see
213 .BR attributes (7).
214 .TS
215 allbox;
216 lb lb lb
217 l l l.
218 Interface Attribute Value
219 T{
220 .BR tzset ()
221 T} Thread safety MT-Safe env locale
222 .TE
223 .SH CONFORMING TO
224 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
225 .SH NOTES
226 Note that the variable \fIdaylight\fP does not indicate that daylight
227 saving time applies right now.
228 It used to give the number of some
229 algorithm (see the variable \fItz_dsttime\fP in
230 .BR gettimeofday (2)).
231 It has been obsolete for many years but is required by SUSv2.
232 .LP
233 4.3BSD had a function
234 .BI "char *timezone(" zone ", " dst )
235 that returned the
236 name of the timezone corresponding to its first argument (minutes
237 West of UTC).
238 If the second argument was 0, the standard name was used,
239 otherwise the daylight saving time version.
240 .SH SEE ALSO
241 .BR date (1),
242 .BR gettimeofday (2),
243 .BR time (2),
244 .BR ctime (3),
245 .BR getenv (3),
246 .BR tzfile (5)