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.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93 32.\" 33.Dd March 6, 2023 34.Dt TZSET 3 35.Os 36.Sh NAME 37.Nm tzset 38.Nd initialize time conversion information 39.Sh LIBRARY 40.Lb libc 41.Sh SYNOPSIS 42.In time.h 43.Ft void 44.Fn tzset void 45.Sh DESCRIPTION 46The 47.Fn tzset 48function 49initializes time conversion information used by the library routine 50.Xr localtime 3 . 51The environment variable 52.Ev TZ 53specifies how this is done. 54.Pp 55If 56.Ev TZ 57does not appear in the environment, the best available approximation to 58local wall clock time, as specified by the 59.Xr tzfile 5 Ns -format 60file 61.Pa /etc/localtime 62is used. 63.Pp 64If 65.Ev TZ 66appears in the environment but its value is a null string, Coordinated 67Universal Time 68.Pq Tn UTC 69is used (without leap second correction). 70.Pp 71If 72.Ev TZ 73appears in the environment and its value begins with a colon 74.Pq Ql \&: , 75the rest of its value is used as a pathname of a 76.Xr tzfile 5 Ns -format 77file from which to read the time conversion information. 78If the first character of the pathname is a slash 79.Pq Ql / 80it is used as 81an absolute pathname; otherwise, it is used as a pathname relative to 82the system time conversion information directory. 83.Pp 84If its value does not begin with a colon, it is first used as the pathname 85of a file (as described above) from which to read the time conversion 86information. 87If that file cannot be read, the value is then interpreted as a direct 88specification (the format is described below) of the time conversion 89information. 90.Pp 91If the 92.Ev TZ 93environment variable does not specify a 94.Xr tzfile 5 Ns -format 95file and cannot be interpreted as a direct specification, 96.Tn UTC 97is used. 98.Sh SPECIFICATION FORMAT 99When 100.Ev TZ 101is used directly as a specification of the time conversion information, 102it must have the following syntax (spaces inserted for clarity): 103.Bd -ragged -offset indent 104.Em std offset 105.Bo 106.Em dst 107.Bq Em offset 108.Bq , Em rule 109.Bc 110.Ed 111.Pp 112Where: 113.Bl -tag -width std_and_dst -offset indent 114.It Em std No and Em dst 115Three or more bytes that are the designation for the standard 116.Pq Em std 117or summer 118.Pq Em dst 119time zone. 120Only 121.Em std 122is required; if 123.Em dst 124is missing, then summer time does not apply in this locale. 125Upper and lowercase letters are explicitly allowed. 126Any characters 127except a leading colon 128.Pq Ql \&: , 129digits, comma 130.Pq Ql \&, , 131minus 132.Pq Ql \- , 133plus 134.Pq Ql + , 135and 136.Tn ASCII 137.Dv NUL 138are allowed. 139.It Em offset 140Indicates the value one must add to the local time to arrive at 141Coordinated Universal Time. 142The 143.Em offset 144has the form: 145.Bd -ragged -offset indent 146.Sm off 147.Em hh Bo 148.Em : mm 149.Bq Em : ss 150.Bc 151.Sm on 152.Ed 153.Pp 154The minutes 155.Pq Em mm 156and seconds 157.Pq Em ss 158are optional. 159The hour 160.Pq Em hh 161is required and may be a single digit. 162The 163.Em offset 164following 165.Em std 166is required. 167If no 168.Em offset 169follows 170.Em dst , 171summer time is assumed to be one hour ahead of standard time. 172One or 173more digits may be used; the value is always interpreted as a decimal 174number. 175The hour must be between zero and 24, and the minutes (and 176seconds) \(em if present \(em between zero and 59. 177If preceded by a 178.Pq Ql \- 179the time zone shall be east of the Prime Meridian; otherwise it shall be 180west (which may be indicated by an optional preceding 181.Pq Ql + ) . 182.It Em rule 183Indicates when to change to and back from summer time. 184The 185.Em rule 186has the form: 187.Bd -ragged -offset indent 188.Em date/time,date/time 189.Ed 190.Pp 191where the first 192.Em date 193describes when the change from standard to summer time occurs and the 194second 195.Em date 196describes when the change back happens. 197Each 198.Em time 199field describes when, in current local time, the change to the other 200time is made. 201.Pp 202The format of 203.Em date 204is one of the following: 205.Bl -tag -width "M.m.n.d" 206.It Sy J Em n 207The Julian day 208.Em n 209(1 \*(Le 210.Em n 211\*(Le 365). 212Leap days are not counted; that is, in all years \(em including leap 213years \(em February 28 is day 59 and March 1 is day 60. 214It is 215impossible to explicitly refer to the occasional February 29. 216.It Em n 217The zero-based Julian day 218(0 \*(Le 219.Em n 220\*(Le 365 ) . 221Leap days are counted, and it is possible to refer to February 29. 222.It Sy M Em m.n.d 223The 224.Em d Ns 'th 225day (0 \*(Le 226.Em d 227\*(Le 6) 228of week 229.Em n 230of month 231.Em m 232of the year 233(1 \*(Le 234.Em n 235\*(Le 5), 236(1 \*(Le 237.Em m 238\*(Le 12), 239where week 5 means 240.Do 241the last 242.Em d 243day in month 244.Em m 245.Dc 246which may occur in either the fourth or the fifth week). 247Week 1 is the 248first week in which the 249.Em d Ns 'th 250day occurs. 251Day zero is Sunday. 252.Pp 253The 254.Em time 255has the same format as 256.Em offset 257except that no leading sign 258.Pq Ql \- 259or 260.Pq Ql + 261is allowed. 262The default, if 263.Em time 264is not given, is 265.Sy 02:00:00 . 266.El 267.Pp 268If no 269.Em rule 270is present in the 271.Ev TZ 272specification, the rules specified 273by the 274.Xr tzfile 5 Ns -format 275file 276.Em posixrules 277in the system time conversion information directory are used, with the 278standard and summer time offsets from 279.Tn UTC 280replaced by those specified by 281the 282.Em offset 283values in 284.Ev TZ . 285.El 286.Pp 287For compatibility with System V Release 3.1, a semicolon 288.Pq Ql \&; 289may be used to separate the 290.Em rule 291from the rest of the specification. 292.Sh FILES 293.Bl -tag -width /usr/share/zoneinfo/posixrules -compact 294.It Pa /etc/localtime 295local time zone file 296.It Pa /usr/share/zoneinfo 297time zone directory 298.It Pa /usr/share/zoneinfo/posixrules 299rules for 300.Tn POSIX Ns -style 301.Tn TZ Ns 's 302.It Pa /usr/share/zoneinfo/Etc/GMT 303for 304.Tn UTC 305leap seconds 306.El 307.Pp 308If the file 309.Pa /usr/share/zoneinfo/UTC 310does not exist, 311.Tn UTC 312leap seconds are loaded from 313.Pa /usr/share/zoneinfo/posixrules . 314.Sh SEE ALSO 315.Xr date 1 , 316.Xr gettimeofday 2 , 317.Xr ctime 3 , 318.Xr getenv 3 , 319.Xr time 3 , 320.Xr tzfile 5 321.Sh HISTORY 322The 323.Fn tzset 324function first appeared in 325.Bx 4.4 . 326