[tz] Embedding zone name in tzfile

John Haxby john.haxby at oracle.com
Thu Jan 31 08:55:42 UTC 2013


On 31/01/13 07:48, Alan Barrett wrote:
> On Wed, 30 Jan 2013, Arthur David Olson wrote:
>>> I recently added time zone support to our product, and life would
>>> have been easier if the time zone files had their file name in them
>>> so that they 'knew' what they were.
>>
>>> How come they don't?
>>
>> Some files have multiple names (as established by "Link" directives).
> 
> One name could be blessed as the canonical name, and that could be
> embedded in the file.
> 
> People sometimes want to know: What string could be stored in the TZ
> environment variable on this computer to cause it to use the time zone
> that is the default (described by /etc/localtime or similar) on some
> other computer?  If /etc/localtime is a symlink to
> /usr/share/zoneinfo/Foo/Bar, then the name "Foo/Bar" can easily be
> extracted from that, but if it's a copy instead of a symlink then I
> don't know of any easy answer.


Some software package (icu on Linux, I think), attempts to get the
default timezone by comparing /etc/localtime with everything in
/usr/share/zoneinfo during initialization.    Surprisingly, perhaps,
it's not incredibly slow.   Amusingly it puts the whole of the UK in
Europe/Jersey on the machine I observed this on.

Choosing a canonical name is likely to be more contentious than choosing
the names in the first place.   Symlinks are probably the right way to
go in the future: disk and flash sizes make it increasingly less
attractive to have /usr/share/zoneinfo not part of the root file system
on *ix machines.

jch






More information about the tz mailing list