TZ
¶Although the proleptic format is cumbersome and inaccurate for old timestamps, POSIX.1-2017 and earlier specified details only for the proleptic format, and you may need to use it on small systems that lack a time zone information database.
The proleptic format is:
stdoffset[dst[offset][,
start[/
time],
end[/
time]]]
The std string specifies the time zone abbreviation, which must be at least three bytes long, and which can appear in unquoted or quoted form. The unquoted form can contain only ASCII alphabetic characters. The quoted form can also contain ASCII digits, ‘+’, and ‘-’; it is quoted by surrounding it by ‘<’ and ‘>’, which are not part of the abbreviation. There is no space character separating the time zone abbreviation from the offset, so these restrictions are necessary to parse the specification correctly.
The offset specifies the time value you must add to the local time to get a UTC value. It has syntax like:
[+
|-
]hh[:
mm[:
ss]]
This is positive if the local time zone is west of the Prime Meridian and negative if it is east; this is opposite from the usual convention that positive time zone offsets are east of the Prime Meridian. The hour hh must be between 0 and 24 and may be a single digit, and the minutes mm and seconds ss, if present, must be between 0 and 59.
For example, to specify time in Panama, which is Eastern Standard Time without any daylight saving time alternative:
EST+5
When daylight saving time is used, the proleptic format is more complicated. The initial std and offset specify the standard time zone, as described above. The dst string and offset are the abbreviation and offset for the corresponding daylight saving time zone; if the offset is omitted, it defaults to one hour ahead of standard time.
The remainder of the proleptic format, which starts with the first comma,
describes when daylight saving time is in effect. This remainder is
optional and if omitted, the GNU C Library defaults to the daylight saving
rules that would be used if TZ
had the value "posixrules"
.
However, other POSIX implementations default to different daylight
saving rules, so portable TZ
settings should not omit the
remainder.
In the remainder, the start field is when daylight saving time goes into effect and the end field is when the change is made back to standard time. The following formats are recognized for these fields:
Jn
This specifies the Julian day, with n between 1
and 365
.
February 29 is never counted, even in leap years.
n
This specifies the Julian day, with n between 0
and 365
.
February 29 is counted in leap years.
Mm.w.d
This specifies day d of week w of month m. The day
d must be between 0
(Sunday) and 6
. The week
w must be between 1
and 5
; week 1
is the
first week in which day d occurs, and week 5
specifies the
last d day in the month. The month m should be
between 1
and 12
.
The time fields specify when, in the local time currently in
effect, the change to the other time occurs. They have the same
format as offset except the hours part can range from
−167 through 167; for example, -22:30
stands for 01:30
the previous day and 25:30
stands for 01:30 the next day. If
omitted, time defaults to 02:00:00
.
Here are example TZ
values with daylight saving time rules.
In North American Eastern Standard Time (EST) and Eastern Daylight Time (EDT), the normal offset from UTC is 5 hours; since this is west of the Prime Meridian, the sign is positive. Summer time begins on March’s second Sunday at 2:00am, and ends on November’s first Sunday at 2:00am.
Israel Standard Time (IST) and Israel Daylight Time (IDT) are 2 hours ahead of the prime meridian in winter, springing forward an hour on March’s fourth Thursday 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.
Irish Standard Time (IST) is 1 hour behind the Prime Meridian in summer, falling forward to Greenwich Mean Time (GMT, the Prime Meridian’s time), on October’s last Sunday at 00:00 and springing back on March’s last Sunday at 01:00. This is an example of “negative daylight saving”; here, daylight saving time is one hour west of standard time instead of the more usual one hour east.
Most of Greenland is 2 hours behind UTC in winter. Clocks follow the European Union rules of springing forward by one hour on March’s last Sunday at 01:00 UTC (−01:00 local time) and falling back on October’s last Sunday at 01:00 UTC (00:00 local time). The numeric abbreviations ‘-02’ and ‘-01’ stand for standard and daylight saving time, respectively.
The schedule of daylight saving time in any particular jurisdiction has
changed over the years. To be strictly correct, the conversion of dates
and times in the past should be based on the schedule that was in effect
then. However, the proleptic format does not let you specify how the
schedule has changed from year to year. The most you can do is specify
one particular schedule—usually the present day schedule—and this is
used to convert any date, no matter when. For precise time zone
specifications, it is best to use the geographical format.
See Geographical Format for TZ
.