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