162877Sbostic.\" Copyright (c) 1989, 1991, 1993 262877Sbostic.\" The Regents of the University of California. All rights reserved. 345690Sbostic.\" 445690Sbostic.\" This code is derived from software contributed to Berkeley by 545690Sbostic.\" Arthur Olson. 645690Sbostic.\" 750488Scael.\" %sccs.include.redist.roff% 845690Sbostic.\" 9*64909Sbostic.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93 1050488Scael.\" 1148352Scael.Dd 1248352Scael.Dt TZSET 3 1350488Scael.Os 1448352Scael.Sh NAME 1548352Scael.Nm tzset , 1648352Scael.Nm tzsetwall 1748352Scael.Nd initialize time conversion information 1848352Scael.Sh SYNOPSIS 1948352Scael.Fd #include <time.h> 2048352Scael.Ft void 2148352Scael.Fn tzset void 2248352Scael.Ft void 2348352Scael.Fn tzsetwall void 2448352Scael.Sh DESCRIPTION 2548352ScaelThe 2648352Scael.Fn tzset 2748352Scaelfunction 2845690Sbosticinitializes time conversion information used by the library routine 2948352Scael.Xr localtime 3 . 3045690SbosticThe environment variable 3148352Scael.Ev TZ 3245690Sbosticspecifies how this is done. 3348352Scael.Pp 3445690SbosticIf 3548352Scael.Ev TZ 3645690Sbosticdoes not appear in the environment, the best available approximation to 3745690Sbosticlocal wall clock time, as specified by the 3848352Scael.Xr tzfile 5 Ns -format 3948352Scaelfile 4048352Scael.Pa /etc/localtime 4148352Scaelis used. 4248352Scael.Pp 4345690SbosticIf 4448352Scael.Ev TZ 4545690Sbosticappears in the environment but its value is a null string, Coordinated 4648352ScaelUniversal Time 4748352Scael.Pq Tn UTC 4848352Scaelis used (without leap second correction). 4948352Scael.Pp 5045690SbosticIf 5148352Scael.Ev TZ 5248352Scaelappears in the environment and its value begins with a colon 53*64909Sbostic.Pq Ql \: , 5448352Scaelthe rest of its value is used as a pathname of a 5548352Scael.Xr tzfile 5 Ns -format 5645690Sbosticfile from which to read the time conversion information. 5748352ScaelIf the first character of the pathname is a slash 5848352Scael.Pq Ql / 5948352Scaelit is used as 6045690Sbostican absolute pathname; otherwise, it is used as a pathname relative to 6145690Sbosticthe system time conversion information directory. 6248352Scael.Pp 6345690SbosticIf its value does not begin with a colon, it is first used as the pathname 6445690Sbosticof a file (as described above) from which to read the time conversion 6545690Sbosticinformation. 6645690SbosticIf that file cannot be read, the value is then interpreted as a direct 6745690Sbosticspecification (the format is described below) of the time conversion 6845690Sbosticinformation. 6948352Scael.Pp 7045690SbosticIf the 7148352Scael.Ev TZ 7245690Sbosticenvironment variable does not specify a 7348352Scael.Xr tzfile 5 Ns -format 7445690Sbosticfile and cannot be interpreted as a direct specification, 7548352Scael.Tn UTC 7648352Scaelis used. 7748352Scael.Pp 7848352ScaelThe 7948352Scael.Fn tzsetwall 8048352Scaelfunction 8145690Sbosticsets things up so that 8248352Scael.Xr localtime 8345690Sbosticreturns the best available approximation of local wall clock time. 8448352Scael.Sh SPECIFICATION FORMAT 8545690SbosticWhen 8648352Scael.Ev TZ 8745690Sbosticis used directly as a specification of the time conversion information, 8845690Sbosticit must have the following syntax (spaces inserted for clarity): 8948352Scael.Bd -filled -offset indent 9048352Scael.Em std offset Bo 9148352Scael.Em dst Bo 9248352Scael.Em offset 9348352Scael.Bc 9448352Scael.Bo 9548352Scael.No , Em rule 9648352Scael.Bc 9748352Scael.Bc 9848352Scael.Ed 9948352Scael.Pp 10045690SbosticWhere: 10148352Scael.Bl -tag -width std_and_dst -offset indent 10248352Scael.It Em std No and Em dst 10345690SbosticThree or more bytes that are the designation for the standard 10448352Scael.Pq Em std 10545690Sbosticor summer 10648352Scael.Pq Em dst 10745690Sbostictime zone. Only 10848352Scael.Em std 10945690Sbosticis required; if 11048352Scael.Em dst 11145690Sbosticis missing, then summer time does not apply in this locale. 11248352ScaelUpper and lowercase letters are explicitly allowed. Any characters 11345690Sbosticexcept a leading colon 11448352Scael.Pq Ql : , 11545690Sbosticdigits, comma 11648352Scael.Pq Ql \&, , 11745690Sbosticminus 11848352Scael.Pq Ql \- , 11945690Sbosticplus 12048352Scael.Pq Ql + , 12148352Scaeland 12248352Scael.Tn ASCII 12348352Scael.Dv NUL 12448352Scaelare allowed. 12548352Scael.It Em offset 12645690SbosticIndicates the value one must add to the local time to arrive at 12745690SbosticCoordinated Universal Time. The 12848352Scael.Em offset 12945690Sbostichas the form: 13048352Scael.Bd -unfilled -offset indent 13148352Scael.Em hh Bo 13248352Scael.Pf \&: Em mm 13348352Scael.Bo 13448352Scael.Pf \&: Em ss 13548352Scael.Bc 13648352Scael.Bc 13748352Scael.Ed 13848352Scael.Pp 13945690SbosticThe minutes 14048352Scael.Pq Em mm 14145690Sbosticand seconds 14248352Scael.Pq Em ss 14345690Sbosticare optional. The hour 14448352Scael.Pq Em hh 14545690Sbosticis required and may be a single digit. The 14648352Scael.Em offset 14745690Sbosticfollowing 14848352Scael.Em std 14945690Sbosticis required. If no 15048352Scael.Em offset 15145690Sbosticfollows 15248352Scael.Em dst , 15345690Sbosticsummer time is assumed to be one hour ahead of standard time. One or 15445690Sbosticmore digits may be used; the value is always interpreted as a decimal 15545690Sbosticnumber. The hour must be between zero and 24, and the minutes (and 15645690Sbosticseconds) \(em if present \(em between zero and 59. If preceded by a 15748352Scael.Pq Ql \- 15845690Sbosticthe time zone shall be east of the Prime Meridian; otherwise it shall be 15945690Sbosticwest (which may be indicated by an optional preceding 16048352Scael.Pq Ql + ) . 16148352Scael.It Em rule 16245690SbosticIndicates when to change to and back from summer time. The 16348352Scael.Em rule 16445690Sbostichas the form: 16548352Scael.Bd -filled -offset indent 16648352Scael.Em date/time,date/time 16748352Scael.Ed 16848352Scael.Pp 16945690Sbosticwhere the first 17048352Scael.Em date 17145690Sbosticdescribes when the change from standard to summer time occurs and the 17245690Sbosticsecond 17348352Scael.Em date 17445690Sbosticdescribes when the change back happens. Each 17548352Scael.Em time 17645690Sbosticfield describes when, in current local time, the change to the other 17745690Sbostictime is made. 17848352Scael.Pp 17945690SbosticThe format of 18048352Scael.Em date 18145690Sbosticis one of the following: 18248352Scael.Bl -tag -width "M.m.n.d" 18348352Scael.It Sy J Em n 18445690SbosticThe Julian day 18548352Scael.Em n 18648352Scael(1 \*(Le 18748352Scael.Em n 18848352Scael\*(Le 365). 18945690SbosticLeap days are not counted; that is, in all years \(em including leap 19045690Sbosticyears \(em February 28 is day 59 and March 1 is day 60. It is 19145690Sbosticimpossible to explicitly refer to the occasional February 29. 19248352Scael.It Em n 19345690SbosticThe zero-based Julian day 19448352Scael(0 \*(Le 19548352Scael.Em n 19648352Scael\*(Le 365 ) . 19745690SbosticLeap days are counted, and it is possible to refer to February 29. 19848352Scael.It Sy M Em m.n.d 19945690SbosticThe 20048352Scael.Em d Ns 'th 20148352Scaelday (0 \*(Le 20248352Scael.Em d 20348352Scael\*(Le 6 ) 20445690Sbosticof week 20548352Scael.Em n 20645690Sbosticof month 20748352Scael.Em m 20845690Sbosticof the year 20948352Scael(1 \*(Le 21048352Scael.Em n 21148352Scael\*(Le 5), 21248352Scael(1 \*(Le 21348352Scael.Em m 21448352Scael\*(Le 12), 21548352Scaelwhere week 5 means 21648352Scael.Do 21748352Scaelthe last 21848352Scael.Em d 21945690Sbosticday in month 22048352Scael.Em m 22148352Scael.Dc 22245690Sbosticwhich may occur in either the fourth or the fifth week). Week 1 is the 22345690Sbosticfirst week in which the 22448352Scael.Em d Ns 'th 22545690Sbosticday occurs. Day zero is Sunday. 22648352Scael.Pp 22745690SbosticThe 22848352Scael.Em time 22945690Sbostichas the same format as 23048352Scael.Em offset 23145690Sbosticexcept that no leading sign 23248352Scael.Pq Ql \- 23345690Sbosticor 23448352Scael.Pq Ql + 23545690Sbosticis allowed. The default, if 23648352Scael.Em time 23745690Sbosticis not given, is 23848352Scael.Sy 02:00:00 . 23948352Scael.El 24048352Scael.Pp 24145690SbosticIf no 24248352Scael.Em rule 24348352Scaelis present in the 24448352Scael.Ev TZ 24545690Sbosticspecification, the rules specified 24645690Sbosticby the 24748352Scael.Xr tzfile 5 Ns -format 24845690Sbosticfile 24948352Scael.Em posixrules 25045690Sbosticin the system time conversion information directory are used, with the 25148352Scaelstandard and summer time offsets from 25248352Scael.Tn UTC 25348352Scaelreplaced by those specified by 25445690Sbosticthe 25548352Scael.Em offset 25645690Sbosticvalues in 25748352Scael.Ev TZ . 25848352Scael.El 25948352Scael.Pp 26045690SbosticFor compatibility with System V Release 3.1, a semicolon 26148352Scael.Pq Ql ; 26245690Sbosticmay be used to separate the 26348352Scael.Em rule 26445690Sbosticfrom the rest of the specification. 26548352Scael.Sh FILES 26648352Scael.Bl -tag -width /usr/share/zoneinfo/posixrules -compact 26748352Scael.It Pa /etc/localtime 26848352Scaellocal time zone file 26948352Scael.It Pa /usr/share/zoneinfo 27048352Scaeltime zone directory 27148352Scael.It Pa /usr/share/zoneinfo/posixrules 27248352Scaelrules for 27348352Scael.Tn POSIX Ns -style 27448352Scael.Tn TZ Ns 's 27548352Scael.It Pa /usr/share/zoneinfo/GMT for 27648352Scael.Tn UTC 27748352Scaelleap seconds 27848352Scael.El 27948352Scael.Pp 28048352ScaelIf the file 28148352Scael.Pa /usr/share/zoneinfo/GMT 28248352Scaeldoes not exist, 28348352Scael.Tn UTC 28448352Scaelleap seconds are loaded from 28548352Scael.Pa /usr/share/zoneinfo/posixrules . 28648352Scael.Sh SEE ALSO 28748352Scael.Xr date 1 , 28848352Scael.Xr gettimeofday 2 , 28948352Scael.Xr ctime 3 , 29048352Scael.Xr getenv 3 , 29148352Scael.Xr time 3 , 29248352Scael.Xr tzfile 5 29348352Scael.Sh HISTORY 29448352ScaelThe 29550488Scael.Nm tzset 29648352Scaeland 29750488Scael.Nm tzsetwall 29862876Sbosticfunctions first appeared in 4.4BSD. 299