# How can I keep my timezone data current?



## mackler (Feb 4, 2015)

According to IANA, the current version of the time zone "zoneinfo" database is 2015a.  I installed the port from misc/zoneinfo, but it is giving me version 2014j released last Nov 11.  I also need current timezones for my Java installation, and the java/java-zoneinfo port is giving me the same version from last year.  I ran `portsnap fetch` and `portsnap update` before making the ports. And `freebsd-update fetch` tells me: 
	
	



```
No updates needed to update system to 10.1-RELEASE-p5.
```
Is there a recommended, FreeBSD-specific way to be certain my system and Java are using the most recent zoneinfo data?

Thanks very much,
--
Adam Mackler


----------



## getopt (Feb 4, 2015)

If you run into problems because these ports are not at the latest consider filing a Bug Report


----------



## max21 (Feb 10, 2015)

I posted a few thread last month about Windows in Virtualbox.  FreeBSD is host, running gnome2.  No matter what I did Windows or anything else in Virtualbox would keep time hours ahead or behind by many hours and the day and year were incorrect.  I finally found a half/solution that I now to use.  Since my BIOS used 24-hour format, I got the notion just last week to made 24 hour format default in gnome2 time setting and now the 24-hour clock keeps the correct time.  If you are not using 24 hour format, it could be worth a try.  Lots of people once was having the same problem.  It could be a bug since 10.0 - 10.1p4 (or before) when anyone was using gnome2, I bet.  But I read nothing that said this may be a possibility.  Probably because many are is running a pure server (which usually would use 24-hour format), or using gnome3, or had managed to get MATE-DESKTOP installed (which I can't).  I had run out of guesses a long time ago.  At lease the 24-hour clock does work.  I don't know enough by the port you are trying but If you are not using it, try it.


----------



## mackler (Feb 10, 2015)

max21 said:


> If you are not using 24 hour format, it could be worth a try.



That's very interesting, but is completely irrelevant to my question, which apparently you failed to read.  I am talking about out-of-date timezone data files being distributed in the ports.  Reconfiguring a windowing system that was never installed on my machine cannot help with that.

--
Adam Mackler


----------



## max21 (Feb 13, 2015)

It's a long time habit.  I search google for solutions all day, nearly every day ending up with mostly clues. Now I search for clues.  Late night I found a complete solution on google posted here. After hours of bouncing back and forth from other pages, in the end I come to find it was my own solution from last year and I was the OP.

Anyway, I have been thinking. I looked at /usr/share/zoneinfo and it's all binary. Do they update this yearly? If so, WHY? I thought location timezone never change and these binary files should keep track of time for locations until the end of time. Maybe I'm wrong, but If this is even near correct than as getopt suggested it’s a bug and it could be caused by something else that the Team can't find. _It would be nice for an experienced person who has working files to dump them and send it to you just to see if it works for you.  You can almost replace anything in FreeBSD because everything is a file, and that's a fact._ If it don't work for you than something else has corrupted your zone files. That's all I can figure.  Sorry I could not be of more help.  I'll still be checking around the net anyway.  There are quite a few threads since last year about this and it should not be overlooked any more.


----------



## mackler (Feb 13, 2015)

max21 said:


> I thought location timezone never change...Maybe I'm wrong...



Timezone details change constantly and the maintainer of the zoneinfo file, Paul Eggert seeks to keep the database up-to-date, releasing new versions as necessary.  There were ten different versions released in 2014 alone.

Here is the link to the homepage for the database.  If you look at the mailing list archives you can see all the announcements of new versions.

You can also read the Wikipedia page all about it.

--
Adam Mackler


----------



## mackler (Feb 26, 2015)

I've updated my system zoneinfo manually.  It has turned out to be rather simple—assuming I got it right.  Here's what I did:

*1. Download and extract the newly-released zoneinfo distribution:*

`wget ftp://ftp.iana.org/tz/tzdata-latest.tar.gz
tar -xvzf tzdata-latest.tar.gz`

The distributed tar file contains no directories, so extract this somewhere you won't make a mess.

*2. Check for certain possibly-missing country codes:*

FreeBSD has a file named `/usr/share/misc/iso3166` that contains the two-letter country codes.  Certain of the country codes used by the zoneinfo database could be missing from that file, and if so ought to be removed from the distributed `zone.tab` file downloaded in step 1.  To do this, first grep the `iso3166` file for each, and then comment out the lines for any the missing countries from the `zone.tab` file:

`for m in AX BL BQ CW GG IM JE ME MF RS SS SX
do echo -n $m:
grep -c ^$m /usr/share/misc/iso3166
done`

Look for any zeroes; a zero indicates the associated country-code is missing.  If any code is missing, then find it in `zone.tab` and comment it out.  None of these was missing from my `iso3166` file (FreeBSD 10.1-RELEASE).

*3. Compile the timezones using zic:*

`mkdir zoneinfo
zic -d zoneinfo -p America/New_York -m 444 -L leapseconds -y yearistype.sh \
    africa antarctica asia australasia etcetera europe \
    factory northamerica southamerica systemv`

See the `zic` manual page for an explanation of the `-p` option, and set it appropriately for your machine.

The default behavior of the `zic` utility (without the `-d` option) is to install the compiled files into `/usr/share/zoneinfo`, but here I created a staging directory named `zoneinfo` in order that I could be sure the compilation had completed before deinstalling the currently-installed port.

Note: I got a warning about non-POSIX format abbreviation in the `factory` file, which I ignored.

*4. Install the compiled files:*

At this point the compiled files are in the directory named `zoneinfo`.  Now install these files, and also the `zone.tab` file that came with the distribution.  First deinstall the `zoneinfo` port if necessary (not shown).

`cp zone.tab zoneinfo
cp -R zoneinfo /usr/share`

*5. Finally, reinstall the system default timezone file:*

`tzsetup -r`

And that's it.  One thing I am still confused about is that after deinstalling the port, I still had a copy of the `UTC` file in `/usr/share/zoneinfo`.  I deleted that and replaced in with a copy of the `UTC` file that the above procedure installed into `/usr/share/zoneinfo/Etc`, but I don't know if that helped (nor hurt).

This procedure only addresses the out-of-date `misc/zoneinfo` port.  I still have not dealt with the also out-of-date `java/java-zoneinfo` port.  If I figure that out I'll post my conclusions, but I would still appreciate any assistance on that matter.

--
Adam Mackler


----------



## getopt (Feb 27, 2015)

If your findings confirm that the data of the mentioned ports are not up to date, please contact the maintainers of the ports and/or file a bug report.


----------



## mackler (Mar 4, 2015)

I have updated the zoneinfo data in my Java installation.  Here are instructions for what I did.  Be aware of the zoneinfo-distribution version numbers, and adjust accordingly.  Corrections are invited.

The timezone files are compiled using the `javazic` tool, which is installed in `/usr/local/openjdk7/jre/lib/javazic.jar`.  It has a `-h` option to display usage help that explains its command-line options.

We will use this compiler, specifying, on the command line: the zoneinfo data version, the output directory, and the names of the source files.  For reference, this is the same procedure performed by `openjdk/jdk/make/sun/javazic/Makefile` when compiling the JDK.

First make the destination directory under `/usr/local/share`.  Name it so as to indicate the version of the zoneinfo distribution.

`mkdir /usr/local/share/java/zi2015a`

Now compile the source files.  Enter this command from within the directory whence you extracted the distributed zoneinfo data (see step #1 of my previous post).

`java -jar /usr/local/openjdk7/jre/lib/javazic.jar -V tzdata2015a \
-d /usr/local/share/java/zi2015a \
africa antarctica asia australasia europe northamerica \
pacificnew southamerica backward backzone \
etcetera systemv \
/usr/ports/java/openjdk7/work/openjdk/jdk/make/sun/javazic/tzdata_jdk/gmt \
/usr/ports/java/openjdk7/work/openjdk/jdk/make/sun/javazic/tzdata_jdk/jdk11_backward`

Notes:

You can see that in addition to the new zoneinfo file, we also compiled two files from the openjk distribution, so you might have to `cd /usr/ports/java/openjdk7; make extract` if you don't have it already (or else omit those files).
I omitted the files `solar87`, `solar88`, and `solar89`, which come with Java but not the zoneinfo data.  I'm not sure what they are exactly; apparently it has something to do with Sun's idea of Saudi Arabian time in the late 1980s.  In any event it seems like an invitation to have a discrepancy between Java and my system, so I'm not investigating further.
The `systemv` file in the zoneinfo distribution contains commented-out lines that are uncommented in the java distribution.  If you want them then edit that file before compiling.  If you don't, then the `tzupdater` tool described below will complain about it.
To complete the installation, simply update the symbolic link in the JRE-installation's `lib` directory:

`rm /usr/local/openjdk7/jre/lib/zi
ln -s /usr/local/share/java/zi2015a /usr/local/openjdk7/jre/lib/zi`

Optionally rename the directory that contains the old data to indicate its version:

`mv /usr/local/share/java/zi /usr/local/share/java/zi2014j`

*Checking your work using the Oracle Update Tool*

Oracle distributes a tool that is supposed to do all this for you. Two problems with it are (1) there is a new version for every zoneinfo release, so you have to wait for Oracle to get around to releasing each version, and (2) it may not be compatible with FreeBSD due to the location of installed files.  However, it can be used to confirm that your installed data is consistent with what this tool would have installed (allegedly).

To use it, first go to
`http://www.oracle.com/technetwork/java/javase/downloads/index.html`

Find the "Java Time Zone Updater Tool" and click "download".  Accept the license agreement, and download the zip file.  Make sure it's the correct version.

After unzipping it, running with no options prints help:

`java -jar tzupdater.jar`

The `-t` option will verify your installed zoneinfo files:

`java -jar tzupdater.jar -t`

If you want to use this tool to update the zoneinfo files, then use the `-u` option.  I will be most interested to hear from anyone who has successfully used this tool to perform the entire upgrade process.

--
Adam Mackler


----------

