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