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