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