xref: /csrg-svn/lib/libc/gen/tzset.3 (revision 48352)
1*48352Scael.\" Copyright (c) 1989, 1991 The Regents of the University of California.
245690Sbostic.\" All rights reserved.
345690Sbostic.\"
445690Sbostic.\" This code is derived from software contributed to Berkeley by
545690Sbostic.\" Arthur Olson.
645690Sbostic.\" %sccs.include.redist.man%
745690Sbostic.\"
8*48352Scael.\"     @(#)tzset.3	5.2 (Berkeley) 04/19/91
945690Sbostic.\"
10*48352Scael.Dd
11*48352Scael.Dt TZSET 3
12*48352Scael.Sh NAME
13*48352Scael.Nm tzset ,
14*48352Scael.Nm tzsetwall
15*48352Scael.Nd initialize time conversion information
16*48352Scael.Sh SYNOPSIS
17*48352Scael.Fd #include <time.h>
18*48352Scael.Ft void
19*48352Scael.Fn tzset void
20*48352Scael.Ft void
21*48352Scael.Fn tzsetwall void
22*48352Scael.Sh DESCRIPTION
23*48352ScaelThe
24*48352Scael.Fn tzset
25*48352Scaelfunction
2645690Sbosticinitializes time conversion information used by the library routine
27*48352Scael.Xr localtime 3 .
2845690SbosticThe environment variable
29*48352Scael.Ev TZ
3045690Sbosticspecifies how this is done.
31*48352Scael.Pp
3245690SbosticIf
33*48352Scael.Ev TZ
3445690Sbosticdoes not appear in the environment, the best available approximation to
3545690Sbosticlocal wall clock time, as specified by the
36*48352Scael.Xr tzfile 5 Ns -format
37*48352Scaelfile
38*48352Scael.Pa /etc/localtime
39*48352Scaelis used.
40*48352Scael.Pp
4145690SbosticIf
42*48352Scael.Ev TZ
4345690Sbosticappears in the environment but its value is a null string, Coordinated
44*48352ScaelUniversal Time
45*48352Scael.Pq Tn UTC
46*48352Scaelis used (without leap second correction).
47*48352Scael.Pp
4845690SbosticIf
49*48352Scael.Ev TZ
50*48352Scaelappears in the environment and its value begins with a colon
51*48352Scael.Pq Ql : ,
52*48352Scaelthe rest of its value is used as a pathname of a
53*48352Scael.Xr tzfile 5 Ns -format
5445690Sbosticfile from which to read the time conversion information.
55*48352ScaelIf the first character of the pathname is a slash
56*48352Scael.Pq Ql /
57*48352Scaelit is used as
5845690Sbostican absolute pathname; otherwise, it is used as a pathname relative to
5945690Sbosticthe system time conversion information directory.
60*48352Scael.Pp
6145690SbosticIf its value does not begin with a colon, it is first used as the pathname
6245690Sbosticof a file (as described above) from which to read the time conversion
6345690Sbosticinformation.
6445690SbosticIf that file cannot be read, the value is then interpreted as a direct
6545690Sbosticspecification (the format is described below) of the time conversion
6645690Sbosticinformation.
67*48352Scael.Pp
6845690SbosticIf the
69*48352Scael.Ev TZ
7045690Sbosticenvironment variable does not specify a
71*48352Scael.Xr tzfile 5 Ns -format
7245690Sbosticfile and cannot be interpreted as a direct specification,
73*48352Scael.Tn UTC
74*48352Scaelis used.
75*48352Scael.Pp
76*48352ScaelThe
77*48352Scael.Fn tzsetwall
78*48352Scaelfunction
7945690Sbosticsets things up so that
80*48352Scael.Xr localtime
8145690Sbosticreturns the best available approximation of local wall clock time.
82*48352Scael.Sh SPECIFICATION FORMAT
8345690SbosticWhen
84*48352Scael.Ev TZ
8545690Sbosticis used directly as a specification of the time conversion information,
8645690Sbosticit must have the following syntax (spaces inserted for clarity):
87*48352Scael.Bd -filled -offset indent
88*48352Scael.Em std offset Bo
89*48352Scael.Em dst Bo
90*48352Scael.Em offset
91*48352Scael.Bc
92*48352Scael.Bo
93*48352Scael.No , Em rule
94*48352Scael.Bc
95*48352Scael.Bc
96*48352Scael.Ed
97*48352Scael.Pp
9845690SbosticWhere:
99*48352Scael.Bl -tag -width std_and_dst -offset indent
100*48352Scael.It Em std No and Em dst
10145690SbosticThree or more bytes that are the designation for the standard
102*48352Scael.Pq Em std
10345690Sbosticor summer
104*48352Scael.Pq Em dst
10545690Sbostictime zone.  Only
106*48352Scael.Em std
10745690Sbosticis required; if
108*48352Scael.Em dst
10945690Sbosticis missing, then summer time does not apply in this locale.
110*48352ScaelUpper and lowercase letters are explicitly allowed.  Any characters
11145690Sbosticexcept a leading colon
112*48352Scael.Pq Ql : ,
11345690Sbosticdigits, comma
114*48352Scael.Pq Ql \&, ,
11545690Sbosticminus
116*48352Scael.Pq Ql \- ,
11745690Sbosticplus
118*48352Scael.Pq Ql + ,
119*48352Scaeland
120*48352Scael.Tn ASCII
121*48352Scael.Dv NUL
122*48352Scaelare allowed.
123*48352Scael.It Em offset
12445690SbosticIndicates the value one must add to the local time to arrive at
12545690SbosticCoordinated Universal Time.  The
126*48352Scael.Em offset
12745690Sbostichas the form:
128*48352Scael.Bd -unfilled -offset indent
129*48352Scael.Em hh Bo
130*48352Scael.Pf \&: Em mm
131*48352Scael.Bo
132*48352Scael.Pf \&: Em ss
133*48352Scael.Bc
134*48352Scael.Bc
135*48352Scael.Ed
136*48352Scael.Pp
13745690SbosticThe minutes
138*48352Scael.Pq Em mm
13945690Sbosticand seconds
140*48352Scael.Pq Em ss
14145690Sbosticare optional.  The hour
142*48352Scael.Pq Em hh
14345690Sbosticis required and may be a single digit.  The
144*48352Scael.Em offset
14545690Sbosticfollowing
146*48352Scael.Em std
14745690Sbosticis required.  If no
148*48352Scael.Em offset
14945690Sbosticfollows
150*48352Scael.Em dst ,
15145690Sbosticsummer time is assumed to be one hour ahead of standard time.  One or
15245690Sbosticmore digits may be used; the value is always interpreted as a decimal
15345690Sbosticnumber.  The hour must be between zero and 24, and the minutes (and
15445690Sbosticseconds) \(em if present \(em between zero and 59.  If preceded by a
155*48352Scael.Pq Ql \-
15645690Sbosticthe time zone shall be east of the Prime Meridian; otherwise it shall be
15745690Sbosticwest (which may be indicated by an optional preceding
158*48352Scael.Pq Ql + ) .
159*48352Scael.It Em rule
16045690SbosticIndicates when to change to and back from summer time.  The
161*48352Scael.Em rule
16245690Sbostichas the form:
163*48352Scael.Bd -filled -offset indent
164*48352Scael.Em date/time,date/time
165*48352Scael.Ed
166*48352Scael.Pp
16745690Sbosticwhere the first
168*48352Scael.Em date
16945690Sbosticdescribes when the change from standard to summer time occurs and the
17045690Sbosticsecond
171*48352Scael.Em date
17245690Sbosticdescribes when the change back happens.  Each
173*48352Scael.Em time
17445690Sbosticfield describes when, in current local time, the change to the other
17545690Sbostictime is made.
176*48352Scael.Pp
17745690SbosticThe format of
178*48352Scael.Em date
17945690Sbosticis one of the following:
180*48352Scael.Bl -tag -width "M.m.n.d"
181*48352Scael.It Sy J Em n
18245690SbosticThe Julian day
183*48352Scael.Em n
184*48352Scael(1 \*(Le
185*48352Scael.Em n
186*48352Scael\*(Le 365).
18745690SbosticLeap days are not counted; that is, in all years \(em including leap
18845690Sbosticyears \(em February 28 is day 59 and March 1 is day 60.  It is
18945690Sbosticimpossible to explicitly refer to the occasional February 29.
190*48352Scael.It Em n
19145690SbosticThe zero-based Julian day
192*48352Scael(0 \*(Le
193*48352Scael.Em n
194*48352Scael\*(Le 365 ) .
19545690SbosticLeap days are counted, and it is possible to refer to February 29.
196*48352Scael.It Sy M  Em m.n.d
19745690SbosticThe
198*48352Scael.Em d Ns 'th
199*48352Scaelday (0 \*(Le
200*48352Scael.Em d
201*48352Scael\*(Le 6 )
20245690Sbosticof week
203*48352Scael.Em n
20445690Sbosticof month
205*48352Scael.Em m
20645690Sbosticof the year
207*48352Scael(1 \*(Le
208*48352Scael.Em n
209*48352Scael\*(Le 5),
210*48352Scael(1 \*(Le
211*48352Scael.Em m
212*48352Scael\*(Le 12),
213*48352Scaelwhere week 5 means
214*48352Scael.Do
215*48352Scaelthe last
216*48352Scael.Em d
21745690Sbosticday in month
218*48352Scael.Em m
219*48352Scael.Dc
22045690Sbosticwhich may occur in either the fourth or the fifth week).  Week 1 is the
22145690Sbosticfirst week in which the
222*48352Scael.Em d Ns 'th
22345690Sbosticday occurs.  Day zero is Sunday.
224*48352Scael.Pp
22545690SbosticThe
226*48352Scael.Em time
22745690Sbostichas the same format as
228*48352Scael.Em offset
22945690Sbosticexcept that no leading sign
230*48352Scael.Pq Ql \-
23145690Sbosticor
232*48352Scael.Pq Ql +
23345690Sbosticis allowed.  The default, if
234*48352Scael.Em time
23545690Sbosticis not given, is
236*48352Scael.Sy 02:00:00 .
237*48352Scael.El
238*48352Scael.Pp
23945690SbosticIf no
240*48352Scael.Em rule
241*48352Scaelis present in the
242*48352Scael.Ev TZ
24345690Sbosticspecification, the rules specified
24445690Sbosticby the
245*48352Scael.Xr tzfile 5 Ns -format
24645690Sbosticfile
247*48352Scael.Em posixrules
24845690Sbosticin the system time conversion information directory are used, with the
249*48352Scaelstandard and summer time offsets from
250*48352Scael.Tn UTC
251*48352Scaelreplaced by those specified by
25245690Sbosticthe
253*48352Scael.Em offset
25445690Sbosticvalues in
255*48352Scael.Ev TZ .
256*48352Scael.El
257*48352Scael.Pp
25845690SbosticFor compatibility with System V Release 3.1, a semicolon
259*48352Scael.Pq Ql ;
26045690Sbosticmay be used to separate the
261*48352Scael.Em rule
26245690Sbosticfrom the rest of the specification.
263*48352Scael.Sh FILES
264*48352Scael.Bl -tag -width /usr/share/zoneinfo/posixrules -compact
265*48352Scael.It Pa /etc/localtime
266*48352Scaellocal time zone file
267*48352Scael.It Pa /usr/share/zoneinfo
268*48352Scaeltime zone directory
269*48352Scael.It Pa /usr/share/zoneinfo/posixrules
270*48352Scaelrules for
271*48352Scael.Tn POSIX Ns -style
272*48352Scael.Tn TZ Ns 's
273*48352Scael.It Pa /usr/share/zoneinfo/GMT	for
274*48352Scael.Tn UTC
275*48352Scaelleap seconds
276*48352Scael.El
277*48352Scael.Pp
278*48352ScaelIf the file
279*48352Scael.Pa /usr/share/zoneinfo/GMT
280*48352Scaeldoes not exist,
281*48352Scael.Tn UTC
282*48352Scaelleap seconds are loaded from
283*48352Scael.Pa /usr/share/zoneinfo/posixrules .
284*48352Scael.Sh SEE ALSO
285*48352Scael.Xr date 1 ,
286*48352Scael.Xr gettimeofday 2 ,
287*48352Scael.Xr ctime 3 ,
288*48352Scael.Xr getenv 3 ,
289*48352Scael.Xr time 3 ,
290*48352Scael.Xr tzfile 5
291*48352Scael.Sh HISTORY
292*48352ScaelThe
293*48352Scael.Fn tzset
294*48352Scaeland
295*48352Scael.Fn tzsetwall
296*48352Scaelfunctions are
297*48352Scael.Ud .
298