]> git.saurik.com Git - apple/libc.git/blame - gen/tzset.3
Libc-1244.50.9.tar.gz
[apple/libc.git] / gen / tzset.3
CommitLineData
5b2abdfb
A
1.\" Copyright (c) 1989, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Arthur Olson.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93
36.\" $FreeBSD: src/lib/libc/gen/tzset.3,v 1.12 2001/10/01 16:08:51 ru Exp $
37.\"
38.Dd November 17, 1993
39.Dt TZSET 3
40.Os
41.Sh NAME
42.Nm tzset ,
43.Nm tzsetwall
44.Nd initialize time conversion information
45.Sh LIBRARY
46.Lb libc
47.Sh SYNOPSIS
48.In time.h
49.Ft void
224c7076
A
50.Fo tzset
51.Fa void
52.Fc
5b2abdfb 53.Ft void
224c7076
A
54.Fo tzsetwall
55.Fa void
56.Fc
5b2abdfb
A
57.Sh DESCRIPTION
58The
59.Fn tzset
60function
61initializes time conversion information used by the library routine
62.Xr localtime 3 .
63The environment variable
64.Ev TZ
65specifies how this is done.
66.Pp
67If
68.Ev TZ
69does not appear in the environment, the best available approximation to
70local wall clock time, as specified by the
71.Xr tzfile 5 Ns -format
72file
b5d655f7
A
73#ifdef UNIFDEF_MOVE_LOCALTIME
74.Pa /var/db/timezone/localtime ,
75#else /* !UNIFDEF_MOVE_LOCALTIME */
224c7076 76.Pa /etc/localtime ,
b5d655f7 77#endif /* UNIFDEF_MOVE_LOCALTIME */
5b2abdfb
A
78is used.
79.Pp
80If
81.Ev TZ
224c7076
A
82appears in the environment but its value is a null string,
83Coordinated Universal Time
5b2abdfb
A
84.Pq Tn UTC
85is used (without leap second correction).
86.Pp
87If
88.Ev TZ
89appears in the environment and its value begins with a colon
90.Pq Ql \&: ,
91the rest of its value is used as a pathname of a
92.Xr tzfile 5 Ns -format
93file from which to read the time conversion information.
94If the first character of the pathname is a slash
224c7076 95.Pq Ql / ,
5b2abdfb
A
96it is used as
97an absolute pathname; otherwise, it is used as a pathname relative to
98the system time conversion information directory.
99.Pp
100If its value does not begin with a colon, it is first used as the pathname
101of a file (as described above) from which to read the time conversion
102information.
103If that file cannot be read, the value is then interpreted as a direct
104specification (the format is described below) of the time conversion
105information.
106.Pp
107If the
108.Ev TZ
109environment variable does not specify a
110.Xr tzfile 5 Ns -format
111file and cannot be interpreted as a direct specification,
112.Tn UTC
113is used.
114.Pp
115The
116.Fn tzsetwall
117function
118sets things up so that
119.Xr localtime
120returns the best available approximation of local wall clock time.
121.Sh SPECIFICATION FORMAT
122When
123.Ev TZ
124is used directly as a specification of the time conversion information,
125it must have the following syntax (spaces inserted for clarity):
126.Bd -ragged -offset indent
127.Em std offset
128.Bo
129.Em dst
130.Bq Em offset
131.Bq , Em rule
132.Bc
133.Ed
134.Pp
135Where:
136.Bl -tag -width std_and_dst -offset indent
137.It Em std No and Em dst
138Three or more bytes that are the designation for the standard
139.Pq Em std
140or summer
141.Pq Em dst
142time zone. Only
143.Em std
144is required; if
145.Em dst
146is missing, then summer time does not apply in this locale.
147Upper and lowercase letters are explicitly allowed. Any characters
148except a leading colon
149.Pq Ql \&: ,
150digits, comma
151.Pq Ql \&, ,
152minus
153.Pq Ql \- ,
154plus
155.Pq Ql + ,
156and
157.Tn ASCII
158.Dv NUL
159are allowed.
160.It Em offset
161Indicates the value one must add to the local time to arrive at
162Coordinated Universal Time. The
163.Em offset
164has the form:
165.Bd -ragged -offset indent
166.Sm off
167.Em hh Bo
168.Em : mm
169.Bq Em : ss
170.Bc
171.Sm on
172.Ed
173.Pp
174The minutes
175.Pq Em mm
176and seconds
177.Pq Em ss
178are optional. The hour
179.Pq Em hh
180is required and may be a single digit. The
181.Em offset
182following
183.Em std
184is required. If no
185.Em offset
186follows
187.Em dst ,
188summer time is assumed to be one hour ahead of standard time. One or
189more digits may be used; the value is always interpreted as a decimal
190number. The hour must be between zero and 24, and the minutes (and
191seconds) \(em if present \(em between zero and 59. If preceded by a
192.Pq Ql \-
193the time zone shall be east of the Prime Meridian; otherwise it shall be
194west (which may be indicated by an optional preceding
195.Pq Ql + ) .
196.It Em rule
197Indicates when to change to and back from summer time. The
198.Em rule
199has the form:
200.Bd -ragged -offset indent
201.Em date/time,date/time
202.Ed
203.Pp
204where the first
205.Em date
206describes when the change from standard to summer time occurs and the
207second
208.Em date
209describes when the change back happens. Each
210.Em time
211field describes when, in current local time, the change to the other
212time is made.
213.Pp
214The format of
215.Em date
216is one of the following:
217.Bl -tag -width "M.m.n.d"
218.It Sy J Em n
219The Julian day
220.Em n
221(1 \*(Le
222.Em n
223\*(Le 365).
224Leap days are not counted; that is, in all years \(em including leap
225years \(em February 28 is day 59 and March 1 is day 60. It is
226impossible to explicitly refer to the occasional February 29.
227.It Em n
228The zero-based Julian day
229(0 \*(Le
230.Em n
231\*(Le 365 ) .
232Leap days are counted, and it is possible to refer to February 29.
233.It Sy M Em m.n.d
234The
235.Em d Ns 'th
236day (0 \*(Le
237.Em d
238\*(Le 6)
239of week
240.Em n
241of month
242.Em m
243of the year
244(1 \*(Le
245.Em n
246\*(Le 5),
247(1 \*(Le
248.Em m
249\*(Le 12),
250where week 5 means
251.Do
252the last
253.Em d
254day in month
255.Em m
256.Dc
257which may occur in either the fourth or the fifth week). Week 1 is the
258first week in which the
259.Em d Ns 'th
260day occurs. Day zero is Sunday.
261.Pp
262The
263.Em time
264has the same format as
265.Em offset
266except that no leading sign
267.Pq Ql \-
268or
269.Pq Ql +
270is allowed. The default, if
271.Em time
272is not given, is
273.Sy 02:00:00 .
274.El
275.Pp
276If no
277.Em rule
278is present in the
279.Ev TZ
280specification, the rules specified
281by the
282.Xr tzfile 5 Ns -format
283file
284.Em posixrules
285in the system time conversion information directory are used, with the
286standard and summer time offsets from
287.Tn UTC
288replaced by those specified by
289the
290.Em offset
291values in
292.Ev TZ .
293.El
294.Pp
295For compatibility with System V Release 3.1, a semicolon
296.Pq Ql \&;
297may be used to separate the
298.Em rule
299from the rest of the specification.
300.Sh FILES
6465356a
A
301#ifdef UNIFDEF_TZDIR_SYMLINK
302.ds zi /var/db/timezone/zoneinfo
303#else /* !UNIFDEF_TZDIR_SYMLINK */
304.ds zi /usr/share/zoneinfo
305#endif /* UNIFDEF_TZDIR_SYMLINK */
306.Bl -tag -width \*(zi/posixrules -compact
5b2abdfb
A
307.It Pa /etc/localtime
308local time zone file
6465356a 309.It Pa \*(zi
5b2abdfb 310time zone directory
6465356a 311.It Pa \*(zi/posixrules
5b2abdfb
A
312rules for
313.Tn POSIX Ns -style
314.Tn TZ Ns 's
6465356a 315.It Pa \*(zi/GMT
5b2abdfb
A
316for
317.Tn UTC
318leap seconds
319.El
320.Pp
321If the file
6465356a 322.Pa \*(zi/GMT
5b2abdfb
A
323does not exist,
324.Tn UTC
325leap seconds are loaded from
6465356a 326.Pa \*(zi/posixrules .
5b2abdfb
A
327.Sh SEE ALSO
328.Xr date 1 ,
329.Xr gettimeofday 2 ,
330.Xr ctime 3 ,
331.Xr getenv 3 ,
332.Xr time 3 ,
333.Xr tzfile 5
334.Sh HISTORY
335The
336.Fn tzset
337and
338.Fn tzsetwall
339functions first appeared in
340.Bx 4.4 .