5

We are adding timezone support to our Ubuntu application.

The time zone info on my machine is in /usr/share/zoneinfo.

  1. Is it always in that directory? If so, where is that specified?
  2. If not, is there system call similar to "gettimeofday(2)" that I can make to find out where it is?

Thanks in advance.

1 Answer 1

5

The search location for the time zones is encoded in the C library (where the various time zone aware functions are found):

$ strings -a /lib/x86_64-linux-gnu/libc.so.6 | grep zoneinfo
/usr/share/zoneinfo

The C library code makes use of this directory as a preprocessor #define, so there is no routine to ask what value it was compiled with.

If you need to parse the the time zone data yourself (as opposed to using the few C library routines available), then hard coding /usr/share/zoneinfo should be fine: if your target platforms follow the Linux File System Hierarchy, you should be safe.

If you are only interested in the local time zone, read /etc/localtime, which will be a copy of the relevant file from /usr/share/zoneinfo.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .