1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Arthur Olson. 6.\" 7.\" %sccs.include.redist.roff% 8.\" 9.\" @(#)tzset.3 8.1 (Berkeley) 06/09/93 10.\" 11.Dd 12.Dt TZSET 3 13.Os 14.Sh NAME 15.Nm tzset , 16.Nm tzsetwall 17.Nd initialize time conversion information 18.Sh SYNOPSIS 19.Fd #include <time.h> 20.Ft void 21.Fn tzset void 22.Ft void 23.Fn tzsetwall void 24.Sh DESCRIPTION 25The 26.Fn tzset 27function 28initializes time conversion information used by the library routine 29.Xr localtime 3 . 30The environment variable 31.Ev TZ 32specifies how this is done. 33.Pp 34If 35.Ev TZ 36does not appear in the environment, the best available approximation to 37local wall clock time, as specified by the 38.Xr tzfile 5 Ns -format 39file 40.Pa /etc/localtime 41is used. 42.Pp 43If 44.Ev TZ 45appears in the environment but its value is a null string, Coordinated 46Universal Time 47.Pq Tn UTC 48is used (without leap second correction). 49.Pp 50If 51.Ev TZ 52appears in the environment and its value begins with a colon 53.Pq Ql : , 54the rest of its value is used as a pathname of a 55.Xr tzfile 5 Ns -format 56file from which to read the time conversion information. 57If the first character of the pathname is a slash 58.Pq Ql / 59it is used as 60an absolute pathname; otherwise, it is used as a pathname relative to 61the system time conversion information directory. 62.Pp 63If its value does not begin with a colon, it is first used as the pathname 64of a file (as described above) from which to read the time conversion 65information. 66If that file cannot be read, the value is then interpreted as a direct 67specification (the format is described below) of the time conversion 68information. 69.Pp 70If the 71.Ev TZ 72environment variable does not specify a 73.Xr tzfile 5 Ns -format 74file and cannot be interpreted as a direct specification, 75.Tn UTC 76is used. 77.Pp 78The 79.Fn tzsetwall 80function 81sets things up so that 82.Xr localtime 83returns the best available approximation of local wall clock time. 84.Sh SPECIFICATION FORMAT 85When 86.Ev TZ 87is used directly as a specification of the time conversion information, 88it must have the following syntax (spaces inserted for clarity): 89.Bd -filled -offset indent 90.Em std offset Bo 91.Em dst Bo 92.Em offset 93.Bc 94.Bo 95.No , Em rule 96.Bc 97.Bc 98.Ed 99.Pp 100Where: 101.Bl -tag -width std_and_dst -offset indent 102.It Em std No and Em dst 103Three or more bytes that are the designation for the standard 104.Pq Em std 105or summer 106.Pq Em dst 107time zone. Only 108.Em std 109is required; if 110.Em dst 111is missing, then summer time does not apply in this locale. 112Upper and lowercase letters are explicitly allowed. Any characters 113except a leading colon 114.Pq Ql : , 115digits, comma 116.Pq Ql \&, , 117minus 118.Pq Ql \- , 119plus 120.Pq Ql + , 121and 122.Tn ASCII 123.Dv NUL 124are allowed. 125.It Em offset 126Indicates the value one must add to the local time to arrive at 127Coordinated Universal Time. The 128.Em offset 129has the form: 130.Bd -unfilled -offset indent 131.Em hh Bo 132.Pf \&: Em mm 133.Bo 134.Pf \&: Em ss 135.Bc 136.Bc 137.Ed 138.Pp 139The minutes 140.Pq Em mm 141and seconds 142.Pq Em ss 143are optional. The hour 144.Pq Em hh 145is required and may be a single digit. The 146.Em offset 147following 148.Em std 149is required. If no 150.Em offset 151follows 152.Em dst , 153summer time is assumed to be one hour ahead of standard time. One or 154more digits may be used; the value is always interpreted as a decimal 155number. The hour must be between zero and 24, and the minutes (and 156seconds) \(em if present \(em between zero and 59. If preceded by a 157.Pq Ql \- 158the time zone shall be east of the Prime Meridian; otherwise it shall be 159west (which may be indicated by an optional preceding 160.Pq Ql + ) . 161.It Em rule 162Indicates when to change to and back from summer time. The 163.Em rule 164has the form: 165.Bd -filled -offset indent 166.Em date/time,date/time 167.Ed 168.Pp 169where the first 170.Em date 171describes when the change from standard to summer time occurs and the 172second 173.Em date 174describes when the change back happens. Each 175.Em time 176field describes when, in current local time, the change to the other 177time is made. 178.Pp 179The format of 180.Em date 181is one of the following: 182.Bl -tag -width "M.m.n.d" 183.It Sy J Em n 184The Julian day 185.Em n 186(1 \*(Le 187.Em n 188\*(Le 365). 189Leap days are not counted; that is, in all years \(em including leap 190years \(em February 28 is day 59 and March 1 is day 60. It is 191impossible to explicitly refer to the occasional February 29. 192.It Em n 193The zero-based Julian day 194(0 \*(Le 195.Em n 196\*(Le 365 ) . 197Leap days are counted, and it is possible to refer to February 29. 198.It Sy M Em m.n.d 199The 200.Em d Ns 'th 201day (0 \*(Le 202.Em d 203\*(Le 6 ) 204of week 205.Em n 206of month 207.Em m 208of the year 209(1 \*(Le 210.Em n 211\*(Le 5), 212(1 \*(Le 213.Em m 214\*(Le 12), 215where week 5 means 216.Do 217the last 218.Em d 219day in month 220.Em m 221.Dc 222which may occur in either the fourth or the fifth week). Week 1 is the 223first week in which the 224.Em d Ns 'th 225day occurs. Day zero is Sunday. 226.Pp 227The 228.Em time 229has the same format as 230.Em offset 231except that no leading sign 232.Pq Ql \- 233or 234.Pq Ql + 235is allowed. The default, if 236.Em time 237is not given, is 238.Sy 02:00:00 . 239.El 240.Pp 241If no 242.Em rule 243is present in the 244.Ev TZ 245specification, the rules specified 246by the 247.Xr tzfile 5 Ns -format 248file 249.Em posixrules 250in the system time conversion information directory are used, with the 251standard and summer time offsets from 252.Tn UTC 253replaced by those specified by 254the 255.Em offset 256values in 257.Ev TZ . 258.El 259.Pp 260For compatibility with System V Release 3.1, a semicolon 261.Pq Ql ; 262may be used to separate the 263.Em rule 264from the rest of the specification. 265.Sh FILES 266.Bl -tag -width /usr/share/zoneinfo/posixrules -compact 267.It Pa /etc/localtime 268local time zone file 269.It Pa /usr/share/zoneinfo 270time zone directory 271.It Pa /usr/share/zoneinfo/posixrules 272rules for 273.Tn POSIX Ns -style 274.Tn TZ Ns 's 275.It Pa /usr/share/zoneinfo/GMT for 276.Tn UTC 277leap seconds 278.El 279.Pp 280If the file 281.Pa /usr/share/zoneinfo/GMT 282does not exist, 283.Tn UTC 284leap seconds are loaded from 285.Pa /usr/share/zoneinfo/posixrules . 286.Sh SEE ALSO 287.Xr date 1 , 288.Xr gettimeofday 2 , 289.Xr ctime 3 , 290.Xr getenv 3 , 291.Xr time 3 , 292.Xr tzfile 5 293.Sh HISTORY 294The 295.Nm tzset 296and 297.Nm tzsetwall 298functions first appeared in 4.4BSD. 299