]>
Commit | Line | Data |
---|---|---|
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 | |
33 | tzset, 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 | 45 | The \fBtzset\fP() function initializes the \fItzname\fP variable from the |
c13182ef MK |
46 | TZ environment variable. |
47 | This function is automatically called by the | |
fea681da MK |
48 | other time conversion functions that depend on the time zone. |
49 | In 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 |
51 | have any daylight saving time rules, non-zero if there is a time during |
52 | the year when daylight saving time applies). | |
fea681da MK |
53 | .PP |
54 | If the TZ variable does not appear in the environment, the \fItzname\fP | |
55 | variable is initialized with the best approximation of local wall clock | |
56 | time, as specified by the | |
57 | .BR tzfile (5)-format | |
58 | file \fIlocaltime\fP | |
59 | found in the system timezone directory (see below). | |
60 | (One also often sees | |
61 | .I /etc/localtime | |
62 | used here, a symlink to the right file in the system timezone directory.) | |
63 | .PP | |
67b71557 | 64 | If the TZ variable does appear in the environment but its value is empty |
fea681da MK |
65 | or its value cannot be interpreted using any of the formats specified |
66 | below, Coordinated Universal Time (UTC) is used. | |
67 | .PP | |
c13182ef MK |
68 | The value of TZ can be one of three formats. |
69 | The first format is used | |
fea681da MK |
70 | when 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 |
76 | The \fIstd\fP string specifies the name of the time zone and must be |
77 | three or more alphabetic characters. | |
78 | The \fIoffset\fP string immediately | |
fea681da | 79 | follows \fIstd\fP and specifies the time value to be added to the local |
c13182ef MK |
80 | time to get Coordinated Universal Time (UTC). |
81 | The \fIoffset\fP is positive | |
fea681da | 82 | if the local time zone is west of the Prime Meridian and negative if it is |
c13182ef MK |
83 | east. |
84 | The hour must be between 0 and 24, and the minutes and seconds | |
fea681da MK |
85 | 0 and 59. |
86 | .PP | |
87 | The 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 |
93 | There are no spaces in the specification. |
94 | The initial \fIstd\fP and | |
95 | \fIoffset\fP specify the standard time zone, as described above. | |
96 | The \fIdst\fP string and \fIoffset\fP specify the name and offset for the | |
97 | corresponding daylight saving time zone. | |
98 | If the offset is omitted, | |
e2905dc1 | 99 | it default to one hour ahead of standard time. |
fea681da | 100 | .PP |
e2905dc1 | 101 | The \fIstart\fP field specifies when daylight saving time goes into |
fea681da | 102 | effect and the \fIend\fP field specifies when the change is made back to |
c13182ef MK |
103 | standard time. |
104 | These fields may have the following formats: | |
fea681da MK |
105 | .TP |
106 | J\fIn\fP | |
c13182ef MK |
107 | This specifies the Julian day with \fIn\fP between 1 and 365. |
108 | February 29 is never counted even in leap years. | |
109 | .TP | |
fea681da | 110 | .I n |
c13182ef MK |
111 | This specifies the Julian day with \fIn\fP between 1 and 365. |
112 | February 29 is counted in leap years. | |
113 | .TP | |
fea681da | 114 | M\fIm\fP.\fIw\fP.\fId\fP |
c13182ef MK |
115 | This 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). | |
117 | Week 1 is | |
118 | the first week in which day \fId\fP occurs and week 5 is the last week | |
119 | in which day \fId\fP occurs. | |
120 | Day 0 is a Sunday. | |
fea681da MK |
121 | .PP |
122 | The \fItime\fP fields specify when, in the local time currently in effect, | |
c13182ef MK |
123 | the change to the other time occurs. |
124 | If omitted, the default is 02:00:00. | |
e2905dc1 | 125 | |
c13182ef MK |
126 | Here is an example for New Zealand, |
127 | where the standard time (NZST) is 12 hours ahead of UTC, | |
128 | and daylight saving time (NZDT), 13 hours ahead of UTC, | |
e2905dc1 MK |
129 | runs from the first Sunday in October to the third Sunday in March, |
130 | and 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 |
136 | The third format specifies that the time zone information should be read | |
137 | from a file: | |
138 | .sp | |
139 | .RS | |
140 | :[filespec] | |
141 | .RE | |
142 | .sp | |
143 | If the file specification \fIfilespec\fP is omitted, the time zone | |
144 | information is read from the file | |
145 | .I localtime | |
146 | in the system timezone directory, which nowadays usually is | |
147 | .IR /usr/share/zoneinfo . | |
148 | This file is in | |
149 | .BR tzfile (5) | |
c13182ef MK |
150 | format. |
151 | If \fIfilespec\fP is given, it specifies another | |
fea681da | 152 | .BR tzfile (5)-format |
c13182ef MK |
153 | file to read the time zone information from. |
154 | If \fIfilespec\fP does not begin with a `/', the file specification is | |
fea681da | 155 | relative to the system timezone directory. |
e2905dc1 MK |
156 | .PP |
157 | Here's an example, once more for New Zealand: | |
158 | .nf | |
159 | ||
160 | TZ=":Pacific/Auckland" | |
161 | .fi | |
fea681da MK |
162 | .SH FILES |
163 | The system time zone directory used depends on the (g)libc version. | |
164 | Libc4 and libc5 use | |
165 | .IR /usr/lib/zoneinfo , | |
166 | and, since libc-5.4.6, | |
167 | when this doesn't work, will try | |
168 | .IR /usr/share/zoneinfo . | |
169 | Glibc2 will use the environment variable TZDIR, when that exists. | |
170 | Its default depends on how it was installed, but normally is | |
171 | .IR /usr/share/zoneinfo . | |
172 | .LP | |
173 | This timezone directory contains the files | |
174 | .nf | |
175 | localtime local time zone file | |
176 | posixrules rules for POSIX-style TZ's | |
177 | .fi | |
178 | .LP | |
179 | Often | |
180 | .I /etc/localtime | |
181 | is a symlink to the file | |
182 | .I localtime | |
183 | or to the correct time zone file in the system time zone directory. | |
184 | .SH "CONFORMING TO" | |
68e1685c | 185 | SVr4, POSIX.1-2001, 4.3BSD |
fea681da MK |
186 | .SH NOTES |
187 | Note that the variable \fIdaylight\fP does not indicate that daylight | |
c13182ef MK |
188 | saving time applies right now. |
189 | It used to give the number of some | |
fea681da MK |
190 | algorithm (see the variable \fItz_dsttime\fP in |
191 | .BR gettimeofday (2)). | |
192 | It has been obsolete for many years but is required by SUSv2. | |
193 | .LP | |
122dff10 MK |
194 | 4.3BSD had a function |
195 | .BI "char *timezone(" zone ", " dst ) | |
196 | that returned the | |
fea681da | 197 | name of the time zone corresponding to its first argument (minutes |
c13182ef MK |
198 | West of GMT). |
199 | If the second argument was 0, the standard name was used, | |
e2905dc1 | 200 | otherwise 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) |