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