Preparing Debian for watch change October 26, 2014

Approaching October 26, 2014 - the day when at 2 o’clock in the morning in most regions of Russia for the next (and as promised again the last) time, the clock will be set back an hour. In addition, time zones are changing in some regions. You can familiarize yourself in detail with where and what changes in the Federal Law of July 21, 2014 No. 248-FZ “On Amendments to the Federal Law“ On Calculation of Time ” .

In this post I want to focus on the issue of updating the time zone data in Debian.

Debian uses the timezone database to store information about all time zones in the world(short name tzdata). This database contains complete data on all changes in time zones that have occurred in the world for one reason or another, which allows accurate calculations of local time at any time, starting January 1, 1970. In particular, the current version of tzdata allows you to get the exact local time both during the period before the entry into force of Federal Law No. 248-FZ and after (starting at 2 a.m. on October 26, 2014). In Debian, the tzdata database is distributed as a package of the same name.

The changes that Federal Law No. 248-FZ makes are reflected in the tzdata database starting with version 2014f. As of October 18, 2014, in the official Debian repositories for Wheezy (stable)and Squeeze (oldstable) tzdata package has an earlier version of 2014e, which does not yet provide for the transfer of watches in Russia on October 26, 2014. At the same time, for Jessi (testing) (Update1: from 10.19.2014 and for Wheezy (Stable) the current version of 2014h has already been posted. Thus, in Wheezy and Squueze, to correctly calculate the time after October 26, you will need to install the package yourself. simple: After that, an updated version of tzdata will be installed on the system, however, in order to start using services already running on the system (in particular syslog), you will need to restart them. I will also give an example of a simple script that will check what is on your system the correct bases are used timezones. Script


dpkg -i tzdata_2014h-2_all.deb Checks for the Moscow time zone:
T1=$(LC_ALL=C TZ=Europe/Moscow date -d @1409067890)
if [ "$T1" != 'Tue Aug 26 19:44:50 MSK 2014' ] ; then
    echo FAIL! Wrong TZ BEFORE 26 Oct 2014!
    exit 1
T2=$(LC_ALL=C TZ=Europe/Moscow date -d @1416667890)
if [ "$T2" != 'Sat Nov 22 17:51:30 MSK 2014' ] ; then
    echo FAIL! Wrong TZ AFTER 26 Oct 2014!
    exit 2
echo OK

If everything is in order, an inscription will be displayed OK.

If you have Java installed on your system, then you won’t be able to manage with one tzdata package update. Both OpenJDK and Sun / Oracle Java use their own, separate from system-wide, timezone databases. They will also need to be updated.

In the case of OpenJDK, the base is the tzdata-java package, which has the same version numbers as the tzdata package. Updating it simply by analogy:

dpkg -i tzdata-java_2014h-2_all.deb

In the case of Java from Sun / Oracle, you will need to use the special Java Time Zone Updater Tool , downloading it from the Oracle website. To update the time zone database, you will need to run it with the -u switch

java -jar tzupdater.jar -u

Please note that if you have ever downloaded this utility before, you cannot use this old version - it will not update anything. With each update of the time zone database, Oracle releases a new version of this utility; to get the most current database, you need to use the current version.

As with regular services, already running Java applications may require a restart in order for them to start using the updated version of the time zone database.

Below is an example of Java code that will allow you to check for the Moscow time zone that everything is fine with Java time calculation:
import java.util.*;
import java.text.DateFormat;
public class tzcheck {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Moscow"));
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US);
        cal.setTimeInMillis(1409067890L * 1000L);
        if (!df.format(cal.getTime()).equals("Tuesday, August 26, 2014 7:44:50 PM MSK")) {
            System.out.println("FAIL! Wrong TZ BEFORE 26 Oct 2014!");
        cal.setTimeInMillis(1416667890L * 1000L);
        if (!df.format(cal.getTime()).equals("Saturday, November 22, 2014 5:51:30 PM MSK")) {
            System.out.println("FAIL! Wrong TZ AFTER 26 Oct 2014!");

Compile and run:

java tzcheck

If everything is in order, an inscription will be displayed OK.

Update1: At the weekend, while the post was in moderation, Wheezy released a regular package with the current tzdata + version 2014h-2 was released, the links in the text changed.

Also popular now: