Difference between revisions of "Update timezone files for earlier Daylight Savings Time"

From Christoph's Personal Wiki
Jump to: navigation, search
Line 17: Line 17:
 
Notice that those dates do not correspond to the second Sunday in March nor the first Sunday in November. If you see this in the output, then your DST will not start (or end) on the correct day.
 
Notice that those dates do not correspond to the second Sunday in March nor the first Sunday in November. If you see this in the output, then your DST will not start (or end) on the correct day.
  
The time zone files are using found here:
+
The time zone files are usually found here:
 
  /usr/share/zoneinfo/
 
  /usr/share/zoneinfo/
 
and they are usually linked to the <code>/etc/localtime</code>
 
and they are usually linked to the <code>/etc/localtime</code>

Revision as of 01:23, 8 November 2010

Because of the Energy Policy Act of 2005, beginning in 2007, the United States will begin observing Daylight saving time (DST) from the second Sunday in March until the first Sunday in November.[1]

Older Linux kernels are using the older definition of DST and the files that control this will need to be updated. Below I will show you how to do this.

  • Step 1: Check that you are using the older DST definition.

To determine if your time zone has an issue, run this command (note that zdump might be located under /sbin/zdump or /usr/sbin/zdump):

% zdump -v /etc/localtime | grep 2007

For an example, if you are living in the "Pacific" time zone, you should get something like the following:

/etc/localtime  Sun Apr  1 09:59:59 2007 UTC = Sun Apr  1 01:59:59 2007 PST isdst=0 gmtoff=-28800
/etc/localtime  Sun Apr  1 10:00:00 2007 UTC = Sun Apr  1 03:00:00 2007 PDT isdst=1 gmtoff=-25200
/etc/localtime  Sun Oct 28 08:59:59 2007 UTC = Sun Oct 28 01:59:59 2007 PDT isdst=1 gmtoff=-25200
/etc/localtime  Sun Oct 28 09:00:00 2007 UTC = Sun Oct 28 01:00:00 2007 PST isdst=0 gmtoff=-28800

Notice that those dates do not correspond to the second Sunday in March nor the first Sunday in November. If you see this in the output, then your DST will not start (or end) on the correct day.

The time zone files are usually found here:

/usr/share/zoneinfo/

and they are usually linked to the /etc/localtime

% ls -lah /etc/localtime 
  lrw-r--r--  1 root root 1.1K Jan  5  2006 /etc/localtime ->
  /usr/share/zoneinfo/America/Vancouver
  • Step 2: Download the patch from here. You will need the file tzdata2007c.tar.gz (this may have changed since writing this). Then execute the following commands under the appropriate directory (they are usually located under /usr/share/zoneinfo):
% wget 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz'
% gzip -dc tzcode*.tar.gz | tar -xf -
% gzip -dc tzdata*.tar.gz | tar -xf -
  • Step 3: Since, in our example, we are interested in the files related to the "Pacific" timezone, we will only need "northamerica" and/or "pacificnew". (note: Some modifications where made to the europe and africa files as well, and the last command, zic backwards, will complain if you don't include them.) Here are the commands to run (as root):
% cd /path/to/tzdata2007c
% zic europe
% zic africa 
% zic northamerica 
% zic backwards

Et voilà! Now, check your results with the original command again:

zdump -v /etc/localtime | grep 2007

and you should see something like this:

/etc/localtime  Sun Mar 11 09:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 PST isdst=0 gmtoff=-28800
/etc/localtime  Sun Mar 11 10:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 PDT isdst=1 gmtoff=-25200
/etc/localtime  Sun Nov  4 08:59:59 2007 UTC = Sun Nov  4 01:59:59 2007 PDT isdst=1 gmtoff=-25200
/etc/localtime  Sun Nov  4 09:00:00 2007 UTC = Sun Nov  4 01:00:00 2007 PST isdst=0 gmtoff=-28800

It's the "Mar 11" and "Nov 4" that tell us we have successfully updated our /etc/localtime file.

Sync localtime with rdate

Example: Create a file, e.g. /etc/cron.hourly/time-sync, with the following lines:

#!/bin/bash
/usr/bin/rdate -s time1.u.washington.edu

Remember to make this file executable, like so:

% chmod 775 /etc/cron.hourly/time-sync

References

  1. wikipedia:Daylight saving time

See also

  • zdump — time zone dumper
  • zic — time zone compiler

External links