]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tzset.3
tzset.3: ffix
[thirdparty/man-pages.git] / man3 / tzset.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
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
122dff10
MK
31.\" Modified 2004-12-01 mtk and Martin Schulze <joey@infodrom.org>
32.\"
4b8c67d9 33.TH TZSET 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
34.SH NAME
35tzset, tzname, timezone, daylight \- initialize time conversion information
36.SH SYNOPSIS
37.nf
38.B #include <time.h>
68e4db0a 39.PP
fea681da 40.B void tzset (void);
68e4db0a 41.PP
fea681da
MK
42.BI "extern char *" tzname [2];
43.BI "extern long " timezone ;
44.BI "extern int " daylight ;
45.fi
68e4db0a 46.PP
cc4615cc
MK
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
68e4db0a 51.PP
cc4615cc 52.BR tzset ():
cff459de 53_POSIX_C_SOURCE
cc4615cc
MK
54.br
55.IR tzname :
cff459de 56_POSIX_C_SOURCE
cc4615cc 57.br
d59161f9 58.IR timezone ,
cc4615cc 59.IR daylight :
d59161f9
MK
60_XOPEN_SOURCE
61 || /* Glibc since 2.19: */ _DEFAULT_SOURCE
62 || /* Glibc versions <= 2.19: */ _SVID_SOURCE
fea681da 63.SH DESCRIPTION
60a90ecd
MK
64The
65.BR tzset ()
66function initializes the \fItzname\fP variable from the
097585ed
MK
67.B TZ
68environment variable.
c13182ef 69This function is automatically called by the
5b0dc1ba 70other time conversion functions that depend on the timezone.
464ba7fc 71In a System-V-like environment, it will also set the variables \fItimezone\fP
750d65df 72(seconds West of UTC) and \fIdaylight\fP (to 0 if this timezone does not
17e9724a
CD
73have any daylight saving time rules, or to nonzero if there is a time,
74past, present or future when daylight saving time applies).
fea681da 75.PP
097585ed
MK
76If the
77.B TZ
2c7f2006
J
78variable does not appear in the environment, the system timezone is used.
79The system timezone is configured by copying, or linking, a file in the
b30b425b
MK
80.BR tzfile (5)
81format to
2c7f2006
J
82.IR /etc/localtime .
83A timezone database of these files may be located in the system
84timezone directory (see the \fBFILES\fP section below).
fea681da 85.PP
097585ed
MK
86If the
87.B TZ
343d1314 88variable does appear in the environment, but its value is empty,
fea681da 89or its value cannot be interpreted using any of the formats specified
343d1314 90below, then Coordinated Universal Time (UTC) is used.
fea681da 91.PP
097585ed
MK
92The value of
93.B TZ
411dded2
WP
94can be one of two formats.
95The first format is a string of characters that directly represent the
96timezone to be used:
bdd915e2
MK
97.PP
98.in +4n
99.EX
a288791d 100.IR "std offset" [ dst [ offset ][, start [ /time ], end [ /time ]]]
bdd915e2
MK
101.EE
102.in
103.PP
520d6ed0 104There are no spaces in the specification.
4faf9583 105The \fIstd\fP string specifies an abbreviation for the timezone and must be
c13182ef 106three or more alphabetic characters.
4faf9583
WP
107When enclosed between the less-than (<) and greater-than (>) signs, the
108characters set is expanded to include the plus (+) sign, the minus (-)
109sign, and digits.
c13182ef 110The \fIoffset\fP string immediately
fea681da 111follows \fIstd\fP and specifies the time value to be added to the local
c13182ef
MK
112time to get Coordinated Universal Time (UTC).
113The \fIoffset\fP is positive
5b0dc1ba 114if the local timezone is west of the Prime Meridian and negative if it is
c13182ef 115east.
036ea825 116The hour must be between 0 and 24, and the minutes and seconds 00 and 59:
bdd915e2
MK
117.PP
118.in +4n
119.EX
036ea825 120.RI [ + | - ] hh [ :mm [ :ss ]]
bdd915e2
MK
121.EE
122.in
fea681da 123.PP
c13182ef 124The \fIdst\fP string and \fIoffset\fP specify the name and offset for the
5b0dc1ba 125corresponding daylight saving timezone.
c13182ef 126If the offset is omitted,
343d1314 127it defaults to one hour ahead of standard time.
fea681da 128.PP
e2905dc1 129The \fIstart\fP field specifies when daylight saving time goes into
fea681da 130effect and the \fIend\fP field specifies when the change is made back to
c13182ef
MK
131standard time.
132These fields may have the following formats:
fea681da
MK
133.TP
134J\fIn\fP
c13182ef 135This specifies the Julian day with \fIn\fP between 1 and 365.
567e764a
MK
136Leap days are not counted.
137In this format, February 29 can't be represented;
138February 28 is day 59, and March 1 is always day 60.
c13182ef 139.TP
fea681da 140.I n
567e764a 141This specifies the zero-based Julian day with \fIn\fP between 0 and 365.
c13182ef
MK
142February 29 is counted in leap years.
143.TP
fea681da 144M\fIm\fP.\fIw\fP.\fId\fP
c13182ef
MK
145This specifies day \fId\fP (0 <= \fId\fP <= 6) of week \fIw\fP
146(1 <= \fIw\fP <= 5) of month \fIm\fP (1 <= \fIm\fP <= 12).
147Week 1 is
148the first week in which day \fId\fP occurs and week 5 is the last week
149in which day \fId\fP occurs.
150Day 0 is a Sunday.
fea681da
MK
151.PP
152The \fItime\fP fields specify when, in the local time currently in effect,
c13182ef
MK
153the change to the other time occurs.
154If omitted, the default is 02:00:00.
847e0d88 155.PP
c13182ef
MK
156Here is an example for New Zealand,
157where the standard time (NZST) is 12 hours ahead of UTC,
158and daylight saving time (NZDT), 13 hours ahead of UTC,
e2905dc1
MK
159runs from the first Sunday in October to the third Sunday in March,
160and the changeovers happen at the default time of 02:00:00:
e50b1125 161.PP
bdd915e2
MK
162.in +4n
163.EX
164TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0"
165.EE
166.in
fea681da 167.PP
411dded2 168The second format specifies that the timezone information should be read
fea681da 169from a file:
bdd915e2
MK
170.PP
171.in +4n
172.EX
fea681da 173:[filespec]
bdd915e2
MK
174.EE
175.in
176.PP
4e00a0b8
J
177If the file specification \fIfilespec\fP is omitted, or its value cannot
178be interpreted, then Coordinated Universal Time (UTC) is used.
c13182ef 179If \fIfilespec\fP is given, it specifies another
fea681da 180.BR tzfile (5)-format
5b0dc1ba 181file to read the timezone information from.
f81fb444 182If \fIfilespec\fP does not begin with a \(aq/\(aq, the file specification is
f2671085
MK
183relative to the system timezone directory.
184If the colon is omitted each
411dded2 185of the above \fBTZ\fP formats will be tried.
e2905dc1
MK
186.PP
187Here's an example, once more for New Zealand:
bdd915e2
MK
188.PP
189.in +4n
190.EX
191TZ=":Pacific/Auckland"
192.EE
193.in
c1e90e15
WP
194.SH ENVIRONMENT
195.TP
196.B TZ
197If this variable is set its value takes precedence over the system
198configured timezone.
199.TP
200.B TZDIR
201If this variable is set its value takes precedence over the system
202configured timezone database directory path.
fea681da 203.SH FILES
c1e90e15 204.TP
feb9265d 205.I /etc/localtime
c1e90e15
WP
206The system timezone file.
207.TP
feb9265d 208.I /usr/share/zoneinfo/
c1e90e15
WP
209The system timezone database directory.
210.TP
feb9265d 211.I /usr/share/zoneinfo/posixrules
1cec674c
WP
212When a TZ string includes a dst timezone without anything following it,
213then this file is used for the start/end rules.
214It is in the
b30b425b
MK
215.BR tzfile (5)
216format.
1cec674c
WP
217By default, the zoneinfo Makefile hard links it to the
218.IR America/New_York " tzfile."
c1e90e15
WP
219.PP
220Above are the current standard file locations, but they are
221configurable when glibc is compiled.
1a14cdb6
PH
222.SH ATTRIBUTES
223For an explanation of the terms used in this section, see
224.BR attributes (7).
225.TS
226allbox;
227lb lb lb
228l l l.
229Interface Attribute Value
230T{
231.BR tzset ()
232T} Thread safety MT-Safe env locale
233.TE
47297adb 234.SH CONFORMING TO
595652e0 235POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
fea681da 236.SH NOTES
dd3568a1 237.PP
122dff10
MK
2384.3BSD had a function
239.BI "char *timezone(" zone ", " dst )
240that returned the
5b0dc1ba 241name of the timezone corresponding to its first argument (minutes
750d65df 242West of UTC).
c13182ef 243If the second argument was 0, the standard name was used,
e2905dc1 244otherwise the daylight saving time version.
47297adb 245.SH SEE ALSO
fea681da
MK
246.BR date (1),
247.BR gettimeofday (2),
248.BR time (2),
249.BR ctime (3),
250.BR getenv (3),
251.BR tzfile (5)