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           TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0"
91
92       The second format specifies that the  timezone  information  should  be
93       read from a file:
94
95           :[filespec]
96
97       If  the  file specification filespec is omitted, or its value cannot be
98       interpreted, then Coordinated Universal Time (UTC) is used.   If  file‐
99       spec  is  given, it specifies another tzfile(5)-format file to read the
100       timezone information from.  If filespec does not begin with a '/',  the
101       file  specification  is  relative to the system timezone directory.  If
102       the colon is omitted each of the above TZ formats will be tried.
103
104       Here's an example, once more for New Zealand:
105
106           TZ=":Pacific/Auckland"
107

ENVIRONMENT

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

FILES

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

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

SEE ALSO

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

COLOPHON

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