1TZSET(3)                   Linux Programmer's Manual                  TZSET(3)
2
3
4

NAME

6       tzset, tzname, timezone, daylight - initialize time conversion informa‐
7       tion
8

SYNOPSIS

10       #include <time.h>
11
12       void tzset (void);
13
14       extern char *tzname[2];
15       extern long timezone;
16       extern int daylight;
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       tzset(): _POSIX_C_SOURCE
21       tzname: _POSIX_C_SOURCE
22       timezone, daylight: _XOPEN_SOURCE
23           || /* Glibc since 2.19: */ _DEFAULT_SOURCE
24           || /* Glibc versions <= 2.19: */ _SVID_SOURCE
25

DESCRIPTION

27       The tzset() function initializes the tzname variable from the TZ  envi‐
28       ronment  variable.   This function is automatically called by the other
29       time conversion functions that depend on the timezone.  In a  System-V-
30       like environment, it will also set the variables timezone (seconds West
31       of UTC) and daylight (to 0 if this timezone does not have any  daylight
32       saving  time  rules, or to nonzero if there is a time, past, present or
33       future when daylight saving time applies).
34
35       If the TZ variable does not appear in the environment, the system time‐
36       zone  is  used.  The system timezone is configured by copying, or link‐
37       ing, a file in the tzfile(5)  format  to  /etc/localtime.   A  timezone
38       database of these files may be located in the system timezone directory
39       (see the FILES section below).
40
41       If the TZ variable does appear in the environment,  but  its  value  is
42       empty,  or  its  value  cannot  be interpreted using any of the formats
43       specified below, then Coordinated Universal Time (UTC) is used.
44
45       The value of TZ can be one of two  formats.   The  first  format  is  a
46       string of characters that directly represent the timezone to be used:
47
48           std offset[dst[offset][,start[/time],end[/time]]]
49
50       There  are no spaces in the specification.  The std string specifies an
51       abbreviation for the timezone and must  be  three  or  more  alphabetic
52       characters.   When  enclosed between the less-than (<) and greater-than
53       (>) signs, the characters set is expanded to include the plus (+) sign,
54       the  minus (-) sign, and digits.  The offset string immediately follows
55       std and specifies the time value to be added to the local time  to  get
56       Coordinated  Universal Time (UTC).  The offset is positive if the local
57       timezone is west of the Prime Meridian and negative if it is east.  The
58       hour must be between 0 and 24, and the minutes and seconds 00 and 59:
59
60           [+|-]hh[:mm[:ss]]
61
62       The  dst  string  and offset specify the name and offset for the corre‐
63       sponding daylight saving  timezone.   If  the  offset  is  omitted,  it
64       defaults to one hour ahead of standard time.
65
66       The  start  field  specifies when daylight saving time goes into effect
67       and the end field specifies when the change is made  back  to  standard
68       time.  These fields may have the following formats:
69
70       Jn     This  specifies  the  Julian day with n between 1 and 365.  Leap
71              days are not counted.  In this format, February 29 can't be rep‐
72              resented; February 28 is day 59, and March 1 is always day 60.
73
74       n      This  specifies  the  zero-based Julian day with n between 0 and
75              365.  February 29 is counted in leap years.
76
77       Mm.w.d This specifies day d (0 <= d <= 6) of week w (1 <= w  <=  5)  of
78              month m (1 <= m <= 12).  Week 1 is the first week in which day d
79              occurs and week 5 is the last week in which day d occurs.  Day 0
80              is a Sunday.
81
82       The  time  fields  specify when, in the local time currently in effect,
83       the change to the other  time  occurs.   If  omitted,  the  default  is
84       02:00:00.
85
86       Here  is  an example for New Zealand, where the standard time (NZST) is
87       12 hours ahead of UTC, and daylight saving time (NZDT), 13 hours  ahead
88       of  UTC,  runs  from the first Sunday in October to the third Sunday in
89       March, and the changeovers happen at the default time of 02:00:00:
90
91           TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0"
92
93       The second format specifies that the  timezone  information  should  be
94       read from a file:
95
96           :[filespec]
97
98       If  the  file specification filespec is omitted, or its value cannot be
99       interpreted, then Coordinated Universal Time (UTC) is used.   If  file‐
100       spec  is  given, it specifies another tzfile(5)-format file to read the
101       timezone information from.  If filespec does not begin with a '/',  the
102       file  specification  is  relative to the system timezone directory.  If
103       the colon is omitted each of the above TZ formats will be tried.
104
105       Here's an example, once more for New Zealand:
106
107           TZ=":Pacific/Auckland"
108

ENVIRONMENT

110       TZ     If this variable is set its value takes precedence over the sys‐
111              tem configured timezone.
112
113       TZDIR  If this variable is set its value takes precedence over the sys‐
114              tem configured timezone database directory path.
115

FILES

117       /etc/localtime
118              The system timezone file.
119
120       /usr/share/zoneinfo/
121              The system timezone database directory.
122
123       /usr/share/zoneinfo/posixrules
124              When a TZ string includes a dst timezone without  anything  fol‐
125              lowing  it,  then this file is used for the start/end rules.  It
126              is in the tzfile(5) format.  By default, the  zoneinfo  Makefile
127              hard links it to the America/New_York tzfile.
128
129       Above  are  the  current  standard file locations, but they are config‐
130       urable when glibc is compiled.
131

ATTRIBUTES

133       For  an  explanation  of  the  terms  used   in   this   section,   see
134       attributes(7).
135
136       ┌──────────┬───────────────┬────────────────────┐
137Interface Attribute     Value              
138       ├──────────┼───────────────┼────────────────────┤
139tzset()   │ Thread safety │ MT-Safe env locale │
140       └──────────┴───────────────┴────────────────────┘

CONFORMING TO

142       POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
143

NOTES

145       4.3BSD  had a function char *timezone(zone, dst) that returned the name
146       of the timezone corresponding to its first argument  (minutes  West  of
147       UTC).  If the second argument was 0, the standard name was used, other‐
148       wise the daylight saving time version.
149

SEE ALSO

151       date(1), gettimeofday(2), time(2), ctime(3), getenv(3), tzfile(5)
152

COLOPHON

154       This page is part of release 5.07 of the Linux  man-pages  project.   A
155       description  of  the project, information about reporting bugs, and the
156       latest    version    of    this    page,    can     be     found     at
157       https://www.kernel.org/doc/man-pages/.
158
159
160
161                                  2017-09-15                          TZSET(3)
Impressum