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