]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tzset.3
socket.2: SEE ALSO close(2)
[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.\"
6d322d5f 33.TH TZSET 3 2015-02-21 "" "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>
39.sp
40.B void tzset (void);
41.sp
42.BI "extern char *" tzname [2];
43.BI "extern long " timezone ;
44.BI "extern int " daylight ;
45.fi
cc4615cc
MK
46.sp
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
51.sp
52.BR tzset ():
0f200f07 53_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
cc4615cc
MK
54.br
55.IR tzname :
0f200f07 56_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
cc4615cc
MK
57.br
58.IR timezone :
59_SVID_SOURCE || _XOPEN_SOURCE
60.br
61.IR daylight :
62_SVID_SOURCE || _XOPEN_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
464ba7fc 73have any daylight saving time rules, or to nonzero if there is a time during
e2905dc1 74the year 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
80.BR tzfile "(5) format to"
81.IR /etc/localtime .
82A timezone database of these files may be located in the system
83timezone directory (see the \fBFILES\fP section below).
fea681da 84.PP
097585ed
MK
85If the
86.B TZ
343d1314 87variable does appear in the environment, but its value is empty,
fea681da 88or its value cannot be interpreted using any of the formats specified
343d1314 89below, then Coordinated Universal Time (UTC) is used.
fea681da 90.PP
097585ed
MK
91The value of
92.B TZ
411dded2
WP
93can be one of two formats.
94The first format is a string of characters that directly represent the
95timezone to be used:
fea681da
MK
96.sp
97.RS
a288791d 98.IR "std offset" [ dst [ offset ][, start [ /time ], end [ /time ]]]
fea681da
MK
99.RE
100.sp
520d6ed0 101There are no spaces in the specification.
5b0dc1ba 102The \fIstd\fP string specifies the name of the timezone and must be
c13182ef
MK
103three or more alphabetic characters.
104The \fIoffset\fP string immediately
fea681da 105follows \fIstd\fP and specifies the time value to be added to the local
c13182ef
MK
106time to get Coordinated Universal Time (UTC).
107The \fIoffset\fP is positive
5b0dc1ba 108if the local timezone is west of the Prime Meridian and negative if it is
c13182ef 109east.
036ea825
J
110The hour must be between 0 and 24, and the minutes and seconds 00 and 59:
111.sp
112.RS
113.RI [ + | - ] hh [ :mm [ :ss ]]
114.RE
115.sp
fea681da 116.PP
c13182ef 117The \fIdst\fP string and \fIoffset\fP specify the name and offset for the
5b0dc1ba 118corresponding daylight saving timezone.
c13182ef 119If the offset is omitted,
343d1314 120it defaults to one hour ahead of standard time.
fea681da 121.PP
e2905dc1 122The \fIstart\fP field specifies when daylight saving time goes into
fea681da 123effect and the \fIend\fP field specifies when the change is made back to
c13182ef
MK
124standard time.
125These fields may have the following formats:
fea681da
MK
126.TP
127J\fIn\fP
c13182ef 128This specifies the Julian day with \fIn\fP between 1 and 365.
567e764a
MK
129Leap days are not counted.
130In this format, February 29 can't be represented;
131February 28 is day 59, and March 1 is always day 60.
c13182ef 132.TP
fea681da 133.I n
567e764a 134This specifies the zero-based Julian day with \fIn\fP between 0 and 365.
c13182ef
MK
135February 29 is counted in leap years.
136.TP
fea681da 137M\fIm\fP.\fIw\fP.\fId\fP
c13182ef
MK
138This specifies day \fId\fP (0 <= \fId\fP <= 6) of week \fIw\fP
139(1 <= \fIw\fP <= 5) of month \fIm\fP (1 <= \fIm\fP <= 12).
140Week 1 is
141the first week in which day \fId\fP occurs and week 5 is the last week
142in which day \fId\fP occurs.
143Day 0 is a Sunday.
fea681da
MK
144.PP
145The \fItime\fP fields specify when, in the local time currently in effect,
c13182ef
MK
146the change to the other time occurs.
147If omitted, the default is 02:00:00.
e2905dc1 148
c13182ef
MK
149Here is an example for New Zealand,
150where the standard time (NZST) is 12 hours ahead of UTC,
151and daylight saving time (NZDT), 13 hours ahead of UTC,
e2905dc1
MK
152runs from the first Sunday in October to the third Sunday in March,
153and the changeovers happen at the default time of 02:00:00:
154.nf
155
4b9999d6 156 TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0"
e2905dc1 157.fi
fea681da 158.PP
411dded2 159The second format specifies that the timezone information should be read
fea681da
MK
160from a file:
161.sp
162.RS
163:[filespec]
164.RE
165.sp
4e00a0b8
J
166If the file specification \fIfilespec\fP is omitted, or its value cannot
167be interpreted, then Coordinated Universal Time (UTC) is used.
c13182ef 168If \fIfilespec\fP is given, it specifies another
fea681da 169.BR tzfile (5)-format
5b0dc1ba 170file to read the timezone information from.
f81fb444 171If \fIfilespec\fP does not begin with a \(aq/\(aq, the file specification is
02581204 172relative to the system timezone directory. If the colon is omitted each
411dded2 173of the above \fBTZ\fP formats will be tried.
e2905dc1
MK
174.PP
175Here's an example, once more for New Zealand:
176.nf
177
178 TZ=":Pacific/Auckland"
179.fi
c1e90e15
WP
180.SH ENVIRONMENT
181.TP
182.B TZ
183If this variable is set its value takes precedence over the system
184configured timezone.
185.TP
186.B TZDIR
187If this variable is set its value takes precedence over the system
188configured timezone database directory path.
fea681da 189.SH FILES
c1e90e15 190.TP
feb9265d 191.I /etc/localtime
c1e90e15
WP
192The system timezone file.
193.TP
feb9265d 194.I /usr/share/zoneinfo/
c1e90e15
WP
195The system timezone database directory.
196.TP
feb9265d 197.I /usr/share/zoneinfo/posixrules
1cec674c
WP
198When a TZ string includes a dst timezone without anything following it,
199then this file is used for the start/end rules.
200It is in the
201.BR tzfile "(5) format."
202By default, the zoneinfo Makefile hard links it to the
203.IR America/New_York " tzfile."
c1e90e15
WP
204.PP
205Above are the current standard file locations, but they are
206configurable when glibc is compiled.
1a14cdb6
PH
207.SH ATTRIBUTES
208For an explanation of the terms used in this section, see
209.BR attributes (7).
210.TS
211allbox;
212lb lb lb
213l l l.
214Interface Attribute Value
215T{
216.BR tzset ()
217T} Thread safety MT-Safe env locale
218.TE
47297adb 219.SH CONFORMING TO
44a2c328 220SVr4, POSIX.1-2001, 4.3BSD.
fea681da
MK
221.SH NOTES
222Note that the variable \fIdaylight\fP does not indicate that daylight
c13182ef
MK
223saving time applies right now.
224It used to give the number of some
fea681da
MK
225algorithm (see the variable \fItz_dsttime\fP in
226.BR gettimeofday (2)).
227It has been obsolete for many years but is required by SUSv2.
228.LP
122dff10
MK
2294.3BSD had a function
230.BI "char *timezone(" zone ", " dst )
231that returned the
5b0dc1ba 232name of the timezone corresponding to its first argument (minutes
750d65df 233West of UTC).
c13182ef 234If the second argument was 0, the standard name was used,
e2905dc1 235otherwise the daylight saving time version.
47297adb 236.SH SEE ALSO
fea681da
MK
237.BR date (1),
238.BR gettimeofday (2),
239.BR time (2),
240.BR ctime (3),
241.BR getenv (3),
242.BR tzfile (5)