Getting/Setting the system timezone

Vincent Untz vuntz at gnome.org
Tue Apr 8 09:37:32 PDT 2008


Hi,

I'm having fun with some code to get/set the system timezone. It seems
people like to change how things work :-) Here's what I have so far.
There are probably some errors, and I might miss some stuff...

 + timezone data files are in:
   - /usr/share/zoneinfo for Linux distros (and *BSD?)
   - /usr/share/lib/zoneinfo/tab for OpenSolaris

 + /etc/localtime contains the binary data of the timezone. Sometimes
   it's a copy of a file from /usr/share/zoneinfo, sometimes it's a soft
   link, sometimes it's a hard link (which is bad since /etc and /usr
   can be on different partitions)
   If it's a soft link, it's easy to read the link to know which file is
   used for the timezone.
   If it's a hard link, we can find the right file by comparing inodes.

 + what is the right way to set /etc/localtime? I think copying the file
   is the best thing to do, but I have no idea if that's what all distro
   expect.

 + the timezone is also described in:
   - Fedora/Mandriva: /etc/sysconfig/clock (needs to be parsed to get
     the ZONE= line)
   - openSUSE: /etc/sysconfig/clock (same but with TIMEZONE=)
   - Debian/Ubuntu: /etc/timezone (only contains the name of the
     timezone)
   - openSolaris: (not sure, guessing from some code I have):
     /etc/TIMEZONE (needs to be parsed to get the TZ= line)

So, if I want to set the timezone, I have to change /etc/localtime
(easy) and then to do something which is distro-specific.

First, if your distro is working in a different way, can you tell me
about it?

And second, could we improve this? :-) It's really painful right now...
I'm sure there are other similar system settings that are hard to manage
for the same reason, but the timezone should be easy to solve if we
want.

Vincent

-- 
Les gens heureux ne sont pas pressés.


More information about the Distributions mailing list