]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tzset.3
tfix
[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.
11.\"
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.
19.\"
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
fea681da
MK
46TZ environment variable. This function is automatically called by the
47other time conversion functions that depend on the time zone.
48In a SysV-like environment it will also set the variables \fItimezone\fP
49(seconds West of GMT) and \fIdaylight\fP (0 if this time zone does not
f59a3f19 50have any daylight savings time rules, non-zero if there is a time during
fea681da
MK
51the year when daylight savings time applies).
52.PP
53If the TZ variable does not appear in the environment, the \fItzname\fP
54variable is initialized with the best approximation of local wall clock
55time, as specified by the
56.BR tzfile (5)-format
57file \fIlocaltime\fP
58found in the system timezone directory (see below).
59(One also often sees
60.I /etc/localtime
61used here, a symlink to the right file in the system timezone directory.)
62.PP
67b71557 63If the TZ variable does appear in the environment but its value is empty
fea681da
MK
64or its value cannot be interpreted using any of the formats specified
65below, Coordinated Universal Time (UTC) is used.
66.PP
67The value of TZ can be one of three formats. The first format is used
68when there is no daylight saving time in the local time zone:
69.sp
70.RS
71.I std offset
72.RE
73.sp
74The \fIstd\fP string specifies the name of the time zone and must be
75three or more alphabetic characters. The \fIoffset\fP string immediately
76follows \fIstd\fP and specifies the time value to be added to the local
77time to get Coordinated Universal Time (UTC). The \fIoffset\fP is positive
78if the local time zone is west of the Prime Meridian and negative if it is
79east. The hour must be between 0 and 24, and the minutes and seconds
800 and 59.
81.PP
82The second format is used when there is daylight saving time:
83.sp
84.RS
85.I std offset dst [offset],start[/time],end[/time]
86.RE
87.sp
88There are no spaces in the specification. The initial \fIstd\fP and
89\fIoffset\fP specify the standard time zone, as described above. The
90\fIdst\fP string and \fIoffset\fP specify the name and offset for the
91corresponding daylight savings time zone. If the offset is omitted,
92it defaults to one hour ahead of standard time.
93.PP
94The \fIstart\fP field specifies when daylight savings time goes into
95effect and the \fIend\fP field specifies when the change is made back to
96standard time. These fields may have the following formats:
97.TP
98J\fIn\fP
99This specifies the Julian day with \fIn\fP between 1 and 365. February
10029 is never counted even in leap years.
101.TP
102.I n
103This specifies the Julian day with \fIn\fP between 1 and 365. February
10429 is counted in leap years.
105.TP
106M\fIm\fP.\fIw\fP.\fId\fP
107This specifies day \fId\fP (0 <= \fId\fP <= 6) of week \fIw\fP
108(1 <= \fIw\fP <= 5) of month \fIm\fP (1 <= \fIm\fP <= 12). Week 1 is
109the first week in which day \fId\fP occurs and week 5 is the last week
110in which day \fId\fP occurs. Day 0 is a Sunday.
111.PP
112The \fItime\fP fields specify when, in the local time currently in effect,
113the change to the other time occurs. If omitted, the default is 02:00:00.
114.PP
115The third format specifies that the time zone information should be read
116from a file:
117.sp
118.RS
119:[filespec]
120.RE
121.sp
122If the file specification \fIfilespec\fP is omitted, the time zone
123information is read from the file
124.I localtime
125in the system timezone directory, which nowadays usually is
126.IR /usr/share/zoneinfo .
127This file is in
128.BR tzfile (5)
129format. If \fIfilespec\fP is given, it specifies another
130.BR tzfile (5)-format
131file to read the time zone information from. If
132\fIfilespec\fP does not begin with a `/', the file specification is
133relative to the system timezone directory.
134.SH FILES
135The system time zone directory used depends on the (g)libc version.
136Libc4 and libc5 use
137.IR /usr/lib/zoneinfo ,
138and, since libc-5.4.6,
139when this doesn't work, will try
140.IR /usr/share/zoneinfo .
141Glibc2 will use the environment variable TZDIR, when that exists.
142Its default depends on how it was installed, but normally is
143.IR /usr/share/zoneinfo .
144.LP
145This timezone directory contains the files
146.nf
147localtime local time zone file
148posixrules rules for POSIX-style TZ's
149.fi
150.LP
151Often
152.I /etc/localtime
153is a symlink to the file
154.I localtime
155or to the correct time zone file in the system time zone directory.
156.SH "CONFORMING TO"
68e1685c 157SVr4, POSIX.1-2001, 4.3BSD
fea681da
MK
158.SH NOTES
159Note that the variable \fIdaylight\fP does not indicate that daylight
160savings time applies right now. It used to give the number of some
161algorithm (see the variable \fItz_dsttime\fP in
162.BR gettimeofday (2)).
163It has been obsolete for many years but is required by SUSv2.
164.LP
122dff10
MK
1654.3BSD had a function
166.BI "char *timezone(" zone ", " dst )
167that returned the
fea681da
MK
168name of the time zone corresponding to its first argument (minutes
169West of GMT). If the second argument was 0, the standard name was used,
170otherwise the daylight savings time version.
171.SH "SEE ALSO"
172.BR date (1),
173.BR gettimeofday (2),
174.BR time (2),
175.BR ctime (3),
176.BR getenv (3),
177.BR tzfile (5)