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