convert from ndbm(3) to db(3) interface
[unix-history] / usr / src / lib / libc / gen / tzset.3
CommitLineData
b383a98b
KB
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Arthur Olson.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\" @(#)tzset.3 5.1 (Berkeley) %G%
10.\"
11.TH TZSET 3 ""
12.SH NAME
13tzset, tzsetwall \- initialize time conversion information
14.SH SYNOPSIS
15.nf
16.ft B
17void tzset()
18
19void tzsetwall()
20.ft R
21.fi
22.SH DESCRIPTION
23.I Tzset
24initializes time conversion information used by the library routine
25.IR localtime .
26The environment variable
27.B TZ
28specifies how this is done.
29.PP
30If
31.B TZ
32does not appear in the environment, the best available approximation to
33local wall clock time, as specified by the
34.IR tzfile (5)-format
35file ``/etc/localtime'' is used.
36.PP
37If
38.B TZ
39appears in the environment but its value is a null string, Coordinated
40Universal Time (UTC) is used (without leap second correction).
41.PP
42If
43.B TZ
44appears in the environment and its value begins with a colon (``:''),
45the rest of its value is used as a pathname of a
46.IR tzfile (5)-format
47file from which to read the time conversion information.
48If the first character of the pathname is a slash (``/'') it is used as
49an absolute pathname; otherwise, it is used as a pathname relative to
50the system time conversion information directory.
51.PP
52If its value does not begin with a colon, it is first used as the pathname
53of a file (as described above) from which to read the time conversion
54information.
55If that file cannot be read, the value is then interpreted as a direct
56specification (the format is described below) of the time conversion
57information.
58.PP
59If the
60.B TZ
61environment variable does not specify a
62.IR tzfile (5)-format
63file and cannot be interpreted as a direct specification,
64UTC is used.
65.PP
66.I Tzsetwall
67sets things up so that
68.I localtime
69returns the best available approximation of local wall clock time.
70.SH "SPECIFICATION FORMAT"
71When
72.B TZ
73is used directly as a specification of the time conversion information,
74it must have the following syntax (spaces inserted for clarity):
75.IP
76\fIstd\|offset\fR[\fIdst\fR[\fIoffset\fR][\fB,\fIrule\fR]]
77.PP
78Where:
79.RS
80.TP 15
81.IR std " and " dst
82Three or more bytes that are the designation for the standard
83.RI ( std )
84or summer
85.RI ( dst )
86time zone. Only
87.I std
88is required; if
89.I dst
90is missing, then summer time does not apply in this locale.
91Upper- and lowercase letters are explicitly allowed. Any characters
92except a leading colon
93.RB ( : ),
94digits, comma
95.RB ( , ),
96minus
97.RB ( \(mi ),
98plus
99.RB ( \(pl ),
100and ASCII NUL are allowed.
101.TP
102.I offset
103Indicates the value one must add to the local time to arrive at
104Coordinated Universal Time. The
105.I offset
106has the form:
107.RS
108.IP
109\fIhh\fR[\fB:\fImm\fR[\fB:\fIss\fR]]
110.RE
111.IP
112The minutes
113.RI ( mm )
114and seconds
115.RI ( ss )
116are optional. The hour
117.RI ( hh )
118is required and may be a single digit. The
119.I offset
120following
121.I std
122is required. If no
123.I offset
124follows
125.IR dst ,
126summer time is assumed to be one hour ahead of standard time. One or
127more digits may be used; the value is always interpreted as a decimal
128number. The hour must be between zero and 24, and the minutes (and
129seconds) \(em if present \(em between zero and 59. If preceded by a
130.RB `` \(mi '',
131the time zone shall be east of the Prime Meridian; otherwise it shall be
132west (which may be indicated by an optional preceding
133.RB `` \(pl '').
134.TP
135.I rule
136Indicates when to change to and back from summer time. The
137.I rule
138has the form:
139.RS
140.IP
141\fIdate\fB/\fItime\fB,\fIdate\fB/\fItime\fR
142.RE
143.IP
144where the first
145.I date
146describes when the change from standard to summer time occurs and the
147second
148.I date
149describes when the change back happens. Each
150.I time
151field describes when, in current local time, the change to the other
152time is made.
153.IP
154The format of
155.I date
156is one of the following:
157.RS
158.TP 10
159.BI J n
160The Julian day
161.I n
162.RI "(1\ \(<=" "\ n\ " "\(<=\ 365).
163Leap days are not counted; that is, in all years \(em including leap
164years \(em February 28 is day 59 and March 1 is day 60. It is
165impossible to explicitly refer to the occasional February 29.
166.TP
167.I n
168The zero-based Julian day
169.RI "(0\ \(<=" "\ n\ " "\(<=\ 365).
170Leap days are counted, and it is possible to refer to February 29.
171.TP
172.BI M m . n . d
173The
174.IR d' th
175day
176.RI "(0\ \(<=" "\ d\ " "\(<=\ 6)
177of week
178.I n
179of month
180.I m
181of the year
182.RI "(1\ \(<=" "\ n\ " "\(<=\ 5,
183.RI "1\ \(<=" "\ m\ " "\(<=\ 12,
184where week 5 means ``the last
185.I d
186day in month
187.IR m ''
188which may occur in either the fourth or the fifth week). Week 1 is the
189first week in which the
190.IR d' th
191day occurs. Day zero is Sunday.
192.RE
193.IP "" 15
194The
195.I time
196has the same format as
197.I offset
198except that no leading sign
199.RB (`` \(mi ''
200or
201.RB `` \(pl '')
202is allowed. The default, if
203.I time
204is not given, is
205.BR 02:00:00 .
206.RE
207.LP
208If no
209.I rule
210is present in the
211.BR TZ
212specification, the rules specified
213by the
214.IR tzfile (5)-format
215file
216.B posixrules
217in the system time conversion information directory are used, with the
218standard and summer time offsets from UTC replaced by those specified by
219the
220.I offset
221values in
222.BR TZ .
223.PP
224For compatibility with System V Release 3.1, a semicolon
225.RB ( ; )
226may be used to separate the
227.I rule
228from the rest of the specification.
229.SH FILES
230.ta \w'/usr/share/zoneinfo/posixrules\0\0'u
231/etc/localtime local time zone file
232.br
233/usr/share/zoneinfo time zone directory
234.br
235/usr/share/zoneinfo/posixrules rules for POSIX-style TZ's
236.br
237/usr/share/zoneinfo/GMT for UTC leap seconds
238.sp
239If
240.I /usr/share/zoneinfo/GMT
241is absent, UTC leap seconds are loaded from
242.IR /usr/share/zoneinfo/posixrules .
243.SH SEE ALSO
244date(1), gettimeofday(2), ctime(3), getenv(3), time(3), tzfile(5)