[buug] BUUG 2007-11-01 timezone files, documentation, & related
Michael Paoli
Michael.Paoli at cal.berkeley.edu
Fri Nov 9 20:17:01 PST 2007
BUUG 2007-11-01 timezone files, documentation, & related
At the BUUG 2007-11-01, there was some discussion of timezone files,
finding them, their documentation, their time mappings and checking
them, etc.
First, I'll note, that some of this is a bit GNU/Linux oriented, though
most of it is quite applicable to most any non-ancient Unix flavor
(precise name and location of things may be a bit different, and exactly
what utilities are included for the flavor/distribution will vary).
Secondly, for some earlier discussion on Daylight Saving Time changes
and the like, see also:
daylight saving changes, UNIX/LINUX/... time, etc.
http://www.weak.org/pipermail/buug/2007-March/002907.html
So, ... finding the timezone files, documentation, etc.
$ apropos zone | fgrep -i time | fgrep -v '(3pm)'
timezone (3) [tzset] - initialize time conversion information
tzconfig (8) - set the local timezone
tzfile (5) - time zone information
tzselect (1) - view timezones
tzselect (8) - select a time zone
tzsetup (8) - set the local timezone
zdump (1) - time zone dumper
zic (8) - time zone compiler
Among those, probably most immediately of note,
from tzfile(5) we have:
"as commonly found in /usr/lib/zoneinfo or /usr/share/zoneinfo"
tzconfig(8) is fairly distribution specific, but it usefully includes:
"just updates the link /etc/localtime to point to the correct timezone
installed in /usr/share/zoneinfo/"
So, ... for location of zone files, we're pretty much looking at
/etc/localtime and /usr/share/zoneinfo/ at this point.
So, ... what's our zone?
$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 30 Mar 10 2007 /etc/localtime -> /usr/share/zoneinfo/US
/Pacific
Well, that was easy, ... for other distributions /etc/localtime may be
an ordinary file, rather than a symbolic link. For illustration, let's
pretend we had the harder case.
$ md5sum /etc/localtime
ad7be76a1d7216104d9004a73e200efc /etc/localtime
$ (cd /usr/share/zoneinfo &&
> find * -type f -exec md5sum \{\} \; |
> fgrep ad7be76a1d7216104d9004a73e200efc
> )
ad7be76a1d7216104d9004a73e200efc America/Los_Angeles
ad7be76a1d7216104d9004a73e200efc SystemV/PST8PDT
ad7be76a1d7216104d9004a73e200efc US/Pacific
ad7be76a1d7216104d9004a73e200efc posix/US/Pacific
ad7be76a1d7216104d9004a73e200efc posix/America/Los_Angeles
ad7be76a1d7216104d9004a73e200efc posix/SystemV/PST8PDT
Still not too hard.
We also check and notice:
$ (cd /usr/share/zoneinfo &&
> ls -lion America/Los_Angeles \
> SystemV/PST8PDT \
> US/Pacific \
> posix/US/Pacific \
> posix/America/Los_Angeles \
> posix/SystemV/PST8PDT
> ) |
> sort
119880 -rw-r--r-- 3 0 1017 Nov 28 2006 posix/America/Los_Angeles
119880 -rw-r--r-- 3 0 1017 Nov 28 2006 posix/SystemV/PST8PDT
119880 -rw-r--r-- 3 0 1017 Nov 28 2006 posix/US/Pacific
156021 -rw-r--r-- 1 0 1017 Nov 28 2006 America/Los_Angeles
156106 -rw-r--r-- 1 0 1017 Nov 28 2006 SystemV/PST8PDT
211782 -rw-r--r-- 1 0 1017 Nov 28 2006 US/Pacific
^^^^^^ ^
inode_number link count
Note that several of them are the same file (same inode with multiple
hard links and inode count greater than one). This distribution likely
chose to have some be the same file, as they're alternative names for
zones that would presumably always have the same mappings - or could at
least be later split into separate files if that weren't the case
sometime in the future. And for the others, the distribution likely
chose to have them as separate files, as they might conceivably have
different mappings ... though they happen to all presently match (which
can be verified with cmp(1)).
And something quite useful to examine/check the zones: zdump(1)
E.g.:
$ zdump -v US/Pacific | sed -ne '/ 2007 /{s/^.* UTC = //;p}'
Sun Mar 11 01:59:59 2007 PST isdst=0 gmtoff=-28800
Sun Mar 11 03:00:00 2007 PDT isdst=1 gmtoff=-25200
Sun Nov 4 01:59:59 2007 PDT isdst=1 gmtoff=-25200
Sun Nov 4 01:00:00 2007 PST isdst=0 gmtoff=-28800
But note also, if we look around a bit, we also see slightly different
versions of various timezone files, e.g.:
$ (cd /usr/share/zoneinfo &&
> find * -name PST8PDT -exec md5sum \{\} \;
> ) |
> sort
5d380ebaf6a33f43a07337bfeb28136d right/PST8PDT
698c605c2ab9b8b0cedf5cc0f7bb66cd right/SystemV/PST8PDT
ad7be76a1d7216104d9004a73e200efc SystemV/PST8PDT
ad7be76a1d7216104d9004a73e200efc posix/SystemV/PST8PDT
b04417d20583bdc21e0e6f27f48170fe PST8PDT
b04417d20583bdc21e0e6f27f48170fe posix/PST8PDT
Well, isn't that interesting? So, ... what's different?
After gathering a bit of data and poking around a bit:
$ for tmp in \
> right/PST8PDT \
> right/SystemV/PST8PDT \
> SystemV/PST8PDT \
> PST8PDT
> do
> d=`dirname "$tmp"` || break
> [ -d "$d" ] || mkdir -p "$d"
> d=`dirname "$tmp"` || break
> zdump -v "$tmp" |
> >"$tmp" sed -e 's/^.* UTC = //;s/ [^ ][^ ]* isdst=/ isdst=/'
> done; unset tmp
We see differences such as ...
$ for tmp in \
> right/PST8PDT \
> right/SystemV/PST8PDT \
> SystemV/PST8PDT \
> PST8PDT
> do
> echo "$tmp:"
> fgrep ' 1948 ' "$tmp" | head -1
> fgrep ' 1966 ' "$tmp" | tail -1
> done; unset tmp
How they view offsets in the years 1948 through 1966:
right/PST8PDT:
right/SystemV/PST8PDT:
Sun Mar 14 01:59:59 1948 isdst=0 gmtoff=-28800
Sun Oct 30 01:00:00 1966 isdst=0 gmtoff=-28800
SystemV/PST8PDT:
Sun Mar 14 01:59:59 1948 isdst=0 gmtoff=-28800
Sun Oct 30 01:00:00 1966 isdst=0 gmtoff=-28800
PST8PDT:
$ for tmp in \
> right/PST8PDT \
> right/SystemV/PST8PDT \
> SystemV/PST8PDT \
> PST8PDT
> do
> echo "$tmp:"
> grep 'Dec 31.* 2005 ' "$tmp" | head -1
> done; unset tmp
Whether or not they include (at least certain) leap seconds:
right/PST8PDT:
Sat Dec 31 15:59:60 2005 isdst=0 gmtoff=-28800
right/SystemV/PST8PDT:
Sat Dec 31 15:59:60 2005 isdst=0 gmtoff=-28800
SystemV/PST8PDT:
PST8PDT:
So, ... and where do all these zone files come from?:
$ dpkg -S /usr/share/zoneinfo/US/Pacific
libc6: /usr/share/zoneinfo/US/Pacific
... at least for one flavor, anyway.
Of course those would be compiled zic(8) from source.
There's a fair bit of interesting history in how Unix has evolved from
it's early dealings with timezones up to the timezone files of today -
well solving a rather complex problem pretty well. If you've got a good
tzset(3) man page, or similar, that may give one excellent hints on how
much of the Unix timezone specification and practice has evolved over
the years (noteworthy hint - it remains highly backwards compatible).
More information about the buug
mailing list