minix/lib/libc/time/tzset.3
Lionel Sambuc 84d9c625bf Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
2014-07-28 17:05:06 +02:00

315 lines
7.6 KiB
Groff

.\" $NetBSD: tzset.3,v 1.26 2013/09/20 19:06:54 christos Exp $
.Dd September 20, 2013
.Dt TZSET 3
.Os
.Sh NAME
.Nm tzset
.Nd initialize time conversion information
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In time.h
.Ft void
.Fn tzset "void"
.Sh DESCRIPTION
The
.Fn tzset
function uses the value of the environment variable
.Ev TZ
to set time conversion information used by
.Xr localtime 3 .
If
.Ev TZ
does not appear in the environment,
the best available approximation to local wall clock time, as
specified by the
.Xr tzfile 5
format file
.Pa /etc/localtime
is used by
.Xr localtime 3 .
If
.Ev TZ
appears in the environment but its value is a null string,
Universal Time (UT) is used, with the abbreviation
.Dq UTC
and without leap second correction; please see
.Xr ctime 3 .
If
.Ev TZ
appears in the environment and its value is not a null string:
.Bl -dash
.It
if the value begins with a colon, it is used as a pathname of a file
from which to read the time conversion information;
.It
if the value does not begin with a colon, it is first used as the
pathname of a file from which to read the time conversion information,
and, if that file cannot be read, is used directly as a specification
of the time conversion information.
.El
.Pp
When
.Ev TZ
is used as a pathname, if it begins with a slash, it is used as an
absolute pathname; otherwise, it is used as a pathname relative to
.Pa /usr/share/zoneinfo .
The file must be in the format specified in
.Xr tzfile 5 .
.Pp
When
.Ev TZ
is used directly as a specification of the time conversion information,
it must have the following syntax (spaces inserted for clarity):
.Sm off
.Bd -literal -offset indent
.Cm std Cm offset Oo
.Cm dst Oo
.Cm offset Oc Oo
.No , Cm rule Oc Oc
.Ed
.Sm on
.Pp
where:
.Bl -tag -width "std and dst" -compact
.It Cm std No and Cm dst
Three or more bytes that are the designation for the standard
.Cm ( std )
or summer
.Cm ( dst )
time zone.
Only
.Cm std
is required; if
.Cm dst
is missing, then summer time does not apply in this locale.
Upper- and lowercase letters are explicitly allowed.
Any characters except a leading colon (:), digits, comma (,), minus (-),
plus (+), and ASCII NUL are allowed.
.It Cm offset
Indicates the value one must add to the local time to arrive at
Coordinated Universal Time.
The
.Cm offset
has the form:
.Sm off
.Bd -literal -offset indent
.Cm hh Oo
.Cm :mm Oo
.Cm :ss Oc Oc
.Ed
.Sm on
.Pp
The minutes
.Cm ( mm )
and seconds
.Cm ( ss )
are optional.
The hour
.Cm ( hh )
is required and may be a single digit.
The
.Cm offset
following
.Cm std
is required.
If no
.Cm offset
follows
.Cm dst ,
summer time is assumed to be one hour ahead of standard time.
One or more digits may be used; the value is always interpreted as a
decimal number.
The hour must be between zero and 24, and the minutes (and
seconds) \(em if present \(em between zero and 59.
If preceded by a
.Dq -
the time zone shall be east of the Prime Meridian; otherwise it shall be
west (which may be indicated by an optional preceding
.Dq + ) .
.It Cm rule
Indicates when to change to and back from summer time.
The
.Cm rule
has the form:
.Sm off
.Bd -literal -offset indent
.Xo
.Cm date No /
.Cm time No ,
.Cm date No /
.Cm time
.Xc
.Ed
.Sm on
.Pp
where the first
.Cm date
describes when the change from standard to summer time occurs and the
second
.Cm date
describes when the change back happens.
Each
.Cm time
field describes when, in current local time, the change to the other
time is made.
As an extension to POSIX, daylight saving is assumed to be in effect
all year if it begins January 1 at 00:00 and ends December 31 at
24:00 plus the difference between daylight saving and standard time,
leaving no room for standard time in the calendar.
The format of
.Fa date
is one of the following:
.Bl -tag -width "The Julian day" -compact
.It Cm J Ns Ar n
The Julian day
.Ar n
(1 \*[Le]
.Ar n
\*[Le] 365).
Leap days are not counted; that is, in all years \(em including leap
years \(em February 28 is day 59 and March 1 is day 60.
It is impossible to explicitly refer to the occasional February 29.
.It Ar n
The zero-based Julian day (0\ \*[Le]
.Ar n
\*[Le]\ 365).
Leap days are counted, and it is possible to refer to
February 29.
.Sm off
.It Cm M Ns Ar m No . Ar n No . Ar d
.Sm on
The
.Ar d Ns 'th
day
(0 \*[Le]
.Ar d
\*[Le]\ 6) of week
.Ar n
of month
.Ar m
of the year
(1 \*[Le]
.Ar n
\*[Le]\ 5, 1 \*[Le]
.Ar m
\*[Le]\ 12, where week 5 means
.Dq the\ last Ar d No day\ in\ month Ar m
which may occur in either the fourth or the fifth week).
Week 1 is the first week in which the
.Ar d Ns 'th
day occurs.
Day zero is Sunday.
.El
The
.Cm time
has the same format as
.Cm offset
except that POSIX does not allow a leading sign
.Dq -
or
.Dq +
is allowed.
As an extension to POSIX, the hours part of
.Cm time
can range from \(mi167 through 167; this allows for unusual rules such as
.Dq the Saturday before the first Sunday of March .
The default, if
.Cm time
is not given, is
.Cm 02:00:00 .
.El
.Pp
Here are some examples of
.Va TZ
values that directly specify the time zone rules; they use some of the
extensions to POSIX.
.Bl -tag
.It EST5
stands for US eastern
time (EST), 5 hours behind UTC, without daylight saving.
.It FJT\(mi12FJST,M10.3.1/146,M1.3.4/75
stands for Fiji Time (FJT) and Fiji Summer Time (FJST), 12 hours ahead
of UTC, springing forward on October's third Monday at
146:00 (i.e., 02:00 on the first Sunday on or after October 21), and
falling back on January's third Thursday at 75:00 (i.e., 03:00 on the
first Sunday on or after January 18).
.It IST\(mi2IDT,M3.4.4/26,M10.5.0
stands for Israel Standard Time (IST) and Israel Daylight Time (IDT),
2 hours ahead of UTC, springing forward on March's fourth
Tuesday at 26:00 (i.e., 02:00 on the first Friday on or after March
23), and falling back on October's last Sunday at 02:00.
.It WART4WARST,J1/0,J365/25
stands for Western Argentina Summer Time (WARST), 3 hours behind UTC.
There is a dummy fall-back transition on December 31 at 25:00 daylight
saving time (i.e., 24:00 standard time, equivalent to January 1 at
00:00 standard time), and a simultaneous spring-forward transition on
January 1 at 00:00 standard time, so daylight saving time is in effect
all year and the initial
.Em WART
is a placeholder.
.It WGT3WGST,M3.5.0/\(mi2,M10.5.0/\(mi1
stands for Western Greenland time (WGT) and Western Greenland Summer
Time (WGST), 3 hours behind UTC, where clocks follow the EU rules of
springing forward on March's last Sunday at 01:00 UTC (\(mi02:00 local
time) and falling back on October's last Sunday at 01:00 UTC
(\(mi01:00 local time).
.El
.Pp
If no
.Cm rule
is present in
.Ev TZ ,
the rules specified by the
.Xr tzfile 5
format file
.Pa posixrules
in
.Pa /usr/share/zoneinfo
are used, with the standard and summer time offsets from UTC replaced
by those specified by the
.Cm offset
values in
.Ev TZ .
.Pp
For compatibility with System V Release 3.1, a semicolon (;) may be
used to separate the
.Cm rule
from the rest of the specification.
.Pp
If the
.Ev TZ
environment variable does not specify a
.Xr tzfile 5
format file and cannot be interpreted as a direct specification, UTC
is used.
.Sh FILES
.Bl -tag -width /usr/share/zoneinfo/posixrules -compact
.It Pa /etc/localtime
local time zone file
.It Pa /usr/share/zoneinfo
time zone information directory
.It Pa /usr/share/zoneinfo/posixrules
used with POSIX-style TZ's
.It Pa /usr/share/zoneinfo/GMT
for UTC leap seconds
.El
.Pp
If
.Pa /usr/share/zoneinfo/GMT
is absent, UTC leap seconds are loaded from
.Pa /usr/share/zoneinfo/posixrules .
.Sh SEE ALSO
.Xr ctime 3 ,
.Xr getenv 3 ,
.Xr strftime 3 ,
.Xr time 3 ,
.Xr tzfile 5
.Sh STANDARDS
The
.Fn tzset
function conforms to
.St -p1003.1-88 .
.\" @(#)newtzset.3 8.2
.\" This file is in the public domain, so clarified as of
.\" 2009-05-17 by Arthur David Olson.