MavEtJu's Distorted View of the World

Preparing yourself for changes in DST rules

Posted on 2008-03-27 09:00:09, modified on 2008-03-27 09:00:00
Tags: zoneinfo, DST, Computers

Intro

This year the Daylight Saving Times rules for Australia change: We have two weeks less of wintertime. And the DST change times have been synchronized over all the states. Only problem, how do you make sure your computers know about it?

Find the right times

First you have to find three times which are relevant: before the change, during the changed time, after the change. Since the DST change times have changed from the last weekend in March to the first weekend in April, the times chosen are the wednesdays around the changes: 26 March, 2 April and 9 April.

On FreeBSD:

$ date -r `expr 1206529200` 
Wed Mar 26 22:00:00 EST 2008
$ date -r `expr 1206529200 + 86400 \* 7` 
Wed Apr  2 21:00:00 EST 2008
$ date -r `expr 1206529200 + 86400 \* 14` 
Wed Apr  9 21:00:00 EST 2008
And on Linux:
$ perl -e 'use POSIX;print "Date = ", POSIX::ctime(1206529200 + 86400 * 0);'
Date = Wed Mar 26 22:00:00 2008
$ perl -e 'use POSIX;print "Date = ", POSIX::ctime(1206529200 + 86400 * 7);'
Date = Wed Apr  2 21:00:00 2008
$ perl -e 'use POSIX;print "Date = ", POSIX::ctime(1206529200 + 86400 * 14);'
Date = Wed Apr  9 21:00:00 2008
The second wednesday should have been 22:00 with the new and improved DST rules.

Install the new DST rules

On FreeBSD it is pretty accurate in the CVS repository for HEAD, RELENG_7, RELENG_6 and RELENG_5. If you don't use the RELENG_x versions you can install the port misc/zoneinfo. After that you need to run tzsetup(1). If you have updated your system with freebsd-update(1) you still need to run tzsetup(1)! If you are running jails, they need to be updated too!

for i in /usr/jails/*; do 
        if [ -f $i/etc/localtime ]; then 
		echo $i 
		cp /etc/localtime $i/etc/localtime 
	fi 
done 

If you run Linux, use your package management system: yum install tzdata or apt-get install time.

Or you can do it manually: (The X in 2008X should be resplaced by the value available from elsie.nci.nih.gov)

$ wget ftp://elsie.nci.nih.gov/pub/tzdata2008X.tar.gz 
$ mkdir zoneinfo 
$ cd zoneinfo/ 
$ tar zxf ../tzdata2008X.tar.gz 
$ zic -d zoneinfo africa antarctica asia australasia etcetera \
	europe factory northamerica southamerica systemv 
$ /bin/cp -fR zoneinfo/* /usr/share/zoneinfo/ 
$ /bin/cp zoneinfo/Australia/Sydney /etc/localtime 

Check afterwards

Afterwards, do the checks again to see if changes were successful:

$ date -r `expr 1206529200` 
Wed Mar 26 22:00:00 EST 2008
$ date -r `expr 1206529200 + 86400 \* 7` 
Wed Apr  2 22:00:00 EST 2008
$ date -r `expr 1206529200 + 86400 \* 14` 
Wed Apr  9 21:00:00 EST 2008
As expected!

You should note that all applications need to be restarted to start using the new tzdata files. This includes all FreeBSD jails.

| Share on Facebook | Share on Twitter
Comments:
From: Philip Derrin
URL:
Posted on: 2008-03-28 15:53:53
CommentA simpler way to check that your timezone is correct is to use zdump -v:

$ zdump -v /etc/localtime | grep 2008
/etc/localtime Sat Apr 5 15:59:59 2008 UTC = Sun Apr 6 02:59:59 2008 EST isdst=1
/etc/localtime Sat Apr 5 16:00:00 2008 UTC = Sun Apr 6 02:00:00 2008 EST isdst=0
/etc/localtime Sat Oct 4 15:59:59 2008 UTC = Sun Oct 5 01:59:59 2008 EST isdst=0
/etc/localtime Sat Oct 4 16:00:00 2008 UTC = Sun Oct 5 03:00:00 2008 EST isdst=1

Reply-

Leave a comment
Back to the main page