Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Linux's timezone files always in /usr/share/zoneinfo?

Tags:

timezone

linux

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?

like image 389
Jonathan M Davis Avatar asked Oct 21 '25 18:10

Jonathan M Davis


2 Answers

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.

like image 96
Roman Cheplyaka Avatar answered Oct 24 '25 12:10

Roman Cheplyaka


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.

like image 44
Peter G. Avatar answered Oct 24 '25 14:10

Peter G.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!