[tz] Getting current tzdb version in use

Howard Hinnant howard.hinnant at gmail.com
Thu Jul 19 02:12:58 UTC 2018


The C++20 draft specification leaves the version unspecified, both in its content and its source.  However it is expected that the implementor will make a best attempt to track the IANA database version number.

The prototype implementation first tries the file “version”.  If that file doesn’t exist, it tries to scrape the version number out of NEWS:

    https://github.com/HowardHinnant/date/blob/master/src/tz.cpp#L3316-L3342

On Apple OS's, and if using the OS-supplied zic-compiled files, “+VERSION” is used:

    https://github.com/HowardHinnant/date/blob/master/src/tz.cpp#L2618-L2632

std::lib implementors will be free to provide this information however they best see fit to serve their customers.  Some implementors will probably initially provide an empty string as the version, and my hope is that they will be down-voted in market share.  In time, I hope that C++ std::lib implementors will converge on supplying an accurate representation of the IANA version number, given the standard API for doing so.  Customers will have this standard API in their toolbox, and provide market pressure to their vendors for said API to supply quality results.

Howard

On Jul 18, 2018, at 9:49 PM, Paul G <paul at ganssle.io> wrote:
> 
> Where is it getting the version information? The tzdb files have the `make version` target, but that is not installed with `make install`. There's also the tzdata.zi file, which has the info in the header comment, but I don't think that is consistently deployed in system packages.
> 
>> On July 19, 2018 1:45:14 AM UTC, Howard Hinnant <howard.hinnant at gmail.com> wrote:
>> On Jul 18, 2018, at 9:36 PM, Aldrin Martoq Ahumada <aldrin.martoq at gmail.com> wrote:
>> 
>>  Hi,
>> 
>>  I was looking for a reliable way to get the current tzdb version (something like 2018e), but it seems it doesn’t exists yet. A couple of examples:
>>  - In Mac OS 10.13.6, there is a /usr/share/zoneinfo/+VERSION that says 2018c.
>>  - In one of my updated Ubuntu 16.04 servers, the only reliable way is to do a dpkg -s tzdata | grep ^Version, and guess the real version from the string “Version: 2017c-0ubuntu0.16.04"
>>  - The “tzinfo” ruby library can get the version only if it uses its own version of tzdata, if it uses the OS files, there is no string version.
>> 
>>  Knowing the current tzdb version is essential for automating timezone updates.
>> 
>> 
>>  I think an appropriate place to put that string is in the binary TZif file itself, so tools like tzinfo can get the current version *of the current timezone in use*, instead of looking some random file like +VERSION in a random directory/folder.
>> 
>>  Is there any chances for this to happen? Or any other suggestion?
>> 
>> Fwiw, in the draft C++20 spec, this is a legal program that prints out what you want:
>> 
>>     #include <chrono>
>>     #include <iostream>
>> 
>>     int
>>     main()
>>     {
>>         std::cout << std::chrono::get_tzdb().version << '\n';
>>     }
>> 
>> Howard
>> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mm.icann.org/pipermail/tz/attachments/20180718/bceb5164/signature.asc>


More information about the tz mailing list