tags:

views:

44

answers:

2

I'm writing a program that needs to be able to read in the time zone files on Linux. And that means that I need to be able to consistently find them across distros. As far as I know, they are always located in /usr/share/zoneinfo. The question is, are they in fact always located in /usr/share/zoneinfo? Or are there distros which put them elsewhere? And if so, where do they put them?

+1  A: 

The public-domain time zone database contains the code and data to handle time zones on Linux.

The public-domain time zone database contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules. This database (often called tz or zoneinfo) is used by several implementations, including the GNU C Library used in GNU/Linux, FreeBSD, NetBSD, OpenBSD, Cygwin, DJGPP, AIX, Mac OS X, OpenVMS, Oracle Database, Solaris, Tru64, and UnixWare.

That covers a lot of system but I can only agree with Roman that nobody can be prevented from creating a distribution that differs for whatever reasons. The existence and location of a zonezinfo file is not covered by any official standard as far as I know. The standards (e.g. POSIX and XPG4) only establish the API.

Peter G.
+3  A: 

A quote from tzset(3):

The system timezone directory used depends on the (g)libc version. Libc4 and libc5 use /usr/lib/zoneinfo, and, since libc-5.4.6, when this doesn't work, will try /usr/share/zoneinfo. Glibc2 will use the environment variable TZDIR, when that exists. Its default depends on how it was installed, but normally is /usr/share/zoneinfo.

Note, however, that nothing prevents some perverse distro from patching libc and placing the files wherever they want.

Roman Cheplyaka