]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tzset.3
sync
[thirdparty/man-pages.git] / man3 / tzset.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
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.
6.\"
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.
c13182ef 11.\"
fea681da
MK
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
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" References consulted:
24.\" Linux libc source code
25.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26.\" 386BSD man pages
27.\" Modified Sun Jul 25 11:01:58 1993 by Rik Faith (faith@cs.unc.edu)
28.\" Modified 2001-11-13, aeb
122dff10
MK
29.\" Modified 2004-12-01 mtk and Martin Schulze <joey@infodrom.org>
30.\"
fea681da
MK
31.TH TZSET 3 2001-11-13 "" "Linux Programmer's Manual"
32.SH NAME
33tzset, tzname, timezone, daylight \- initialize time conversion information
34.SH SYNOPSIS
35.nf
36.B #include <time.h>
37.sp
38.B void tzset (void);
39.sp
40.BI "extern char *" tzname [2];
41.BI "extern long " timezone ;
42.BI "extern int " daylight ;
43.fi
44.SH DESCRIPTION
63aa9df0 45The \fBtzset\fP() function initializes the \fItzname\fP variable from the
c13182ef
MK
46TZ environment variable.
47This function is automatically called by the
fea681da
MK
48other time conversion functions that depend on the time zone.
49In a SysV-like environment it will also set the variables \fItimezone\fP
50(seconds West of GMT) and \fIdaylight\fP (0 if this time zone does not
e2905dc1
MK
51have any daylight saving time rules, non-zero if there is a time during
52the year when daylight saving time applies).
fea681da
MK
53.PP
54If the TZ variable does not appear in the environment, the \fItzname\fP
55variable is initialized with the best approximation of local wall clock
56time, as specified by the
57.BR tzfile (5)-format
58file \fIlocaltime\fP
59found in the system timezone directory (see below).
60(One also often sees
61.I /etc/localtime
62used here, a symlink to the right file in the system timezone directory.)
63.PP
67b71557 64If the TZ variable does appear in the environment but its value is empty
fea681da
MK
65or its value cannot be interpreted using any of the formats specified
66below, Coordinated Universal Time (UTC) is used.
67.PP
c13182ef
MK
68The value of TZ can be one of three formats.
69The first format is used
fea681da
MK
70when there is no daylight saving time in the local time zone:
71.sp
72.RS
73.I std offset
74.RE
75.sp
c13182ef
MK
76The \fIstd\fP string specifies the name of the time zone and must be
77three or more alphabetic characters.
78The \fIoffset\fP string immediately
fea681da 79follows \fIstd\fP and specifies the time value to be added to the local
c13182ef
MK
80time to get Coordinated Universal Time (UTC).
81The \fIoffset\fP is positive
fea681da 82if the local time zone is west of the Prime Meridian and negative if it is
c13182ef
MK
83east.
84The hour must be between 0 and 24, and the minutes and seconds
fea681da
MK
850 and 59.
86.PP
87The second format is used when there is daylight saving time:
88.sp
89.RS
90.I std offset dst [offset],start[/time],end[/time]
91.RE
92.sp
c13182ef
MK
93There are no spaces in the specification.
94The initial \fIstd\fP and
95\fIoffset\fP specify the standard time zone, as described above.
96The \fIdst\fP string and \fIoffset\fP specify the name and offset for the
97corresponding daylight saving time zone.
98If the offset is omitted,
e2905dc1 99it default to one hour ahead of standard time.
fea681da 100.PP
e2905dc1 101The \fIstart\fP field specifies when daylight saving time goes into
fea681da 102effect and the \fIend\fP field specifies when the change is made back to
c13182ef
MK
103standard time.
104These fields may have the following formats:
fea681da
MK
105.TP
106J\fIn\fP
c13182ef
MK
107This specifies the Julian day with \fIn\fP between 1 and 365.
108February 29 is never counted even in leap years.
109.TP
fea681da 110.I n
c13182ef
MK
111This specifies the Julian day with \fIn\fP between 1 and 365.
112February 29 is counted in leap years.
113.TP
fea681da 114M\fIm\fP.\fIw\fP.\fId\fP
c13182ef
MK
115This specifies day \fId\fP (0 <= \fId\fP <= 6) of week \fIw\fP
116(1 <= \fIw\fP <= 5) of month \fIm\fP (1 <= \fIm\fP <= 12).
117Week 1 is
118the first week in which day \fId\fP occurs and week 5 is the last week
119in which day \fId\fP occurs.
120Day 0 is a Sunday.
fea681da
MK
121.PP
122The \fItime\fP fields specify when, in the local time currently in effect,
c13182ef
MK
123the change to the other time occurs.
124If omitted, the default is 02:00:00.
e2905dc1 125
c13182ef
MK
126Here is an example for New Zealand,
127where the standard time (NZST) is 12 hours ahead of UTC,
128and daylight saving time (NZDT), 13 hours ahead of UTC,
e2905dc1
MK
129runs from the first Sunday in October to the third Sunday in March,
130and the changeovers happen at the default time of 02:00:00:
131.nf
132
133 TZ="NZST-12.00:00NZDT-13:00:00,M10.1.0,M3.3.0"
134.fi
fea681da
MK
135.PP
136The third format specifies that the time zone information should be read
137from a file:
138.sp
139.RS
140:[filespec]
141.RE
142.sp
143If the file specification \fIfilespec\fP is omitted, the time zone
144information is read from the file
145.I localtime
146in the system timezone directory, which nowadays usually is
147.IR /usr/share/zoneinfo .
148This file is in
149.BR tzfile (5)
c13182ef
MK
150format.
151If \fIfilespec\fP is given, it specifies another
fea681da 152.BR tzfile (5)-format
c13182ef
MK
153file to read the time zone information from.
154If \fIfilespec\fP does not begin with a `/', the file specification is
fea681da 155relative to the system timezone directory.
e2905dc1
MK
156.PP
157Here's an example, once more for New Zealand:
158.nf
159
160 TZ=":Pacific/Auckland"
161.fi
fea681da
MK
162.SH FILES
163The system time zone directory used depends on the (g)libc version.
164Libc4 and libc5 use
165.IR /usr/lib/zoneinfo ,
166and, since libc-5.4.6,
167when this doesn't work, will try
168.IR /usr/share/zoneinfo .
169Glibc2 will use the environment variable TZDIR, when that exists.
170Its default depends on how it was installed, but normally is
171.IR /usr/share/zoneinfo .
172.LP
173This timezone directory contains the files
174.nf
175localtime local time zone file
176posixrules rules for POSIX-style TZ's
177.fi
178.LP
179Often
180.I /etc/localtime
181is a symlink to the file
182.I localtime
183or to the correct time zone file in the system time zone directory.
184.SH "CONFORMING TO"
68e1685c 185SVr4, POSIX.1-2001, 4.3BSD
fea681da
MK
186.SH NOTES
187Note that the variable \fIdaylight\fP does not indicate that daylight
c13182ef
MK
188saving time applies right now.
189It used to give the number of some
fea681da
MK
190algorithm (see the variable \fItz_dsttime\fP in
191.BR gettimeofday (2)).
192It has been obsolete for many years but is required by SUSv2.
193.LP
122dff10
MK
1944.3BSD had a function
195.BI "char *timezone(" zone ", " dst )
196that returned the
fea681da 197name of the time zone corresponding to its first argument (minutes
c13182ef
MK
198West of GMT).
199If the second argument was 0, the standard name was used,
e2905dc1 200otherwise the daylight saving time version.
fea681da
MK
201.SH "SEE ALSO"
202.BR date (1),
203.BR gettimeofday (2),
204.BR time (2),
205.BR ctime (3),
206.BR getenv (3),
207.BR tzfile (5)