[nzlug] Daylight Saving
Michael Field
michael.field at concepts.co.nz
Thu Aug 16 11:22:01 NZST 2007
Here is an earlier post for those running 'unmaintained' distros who
still want the corrected time zones...
Hi All,
As you know NZST now starts last Sunday in September, ending first
Sunday in April. Here's how you can do the updates now, without having
to wait for patches to glibc. I've tested to my satisfaction, but you
will need to do your own testing too!
Make copies of the two files that will get updated:
# cp /usr/share/zoneinfo/Pacific/Auckland /etc/localtime /tmp
Check that the system date is correct to start with:
# date
Wed May 16 10:53:28 NZST 2007
Make a file to hold the updated ZoneInfo source file (the original was
grabbled from a source rpm for glibc, and I've added the lines
2007/2008):
# cat NZ.zi
Rule NZ 1927 only - Nov 26 2:00 0:30
HD
Rule NZ 1928 1929 - Mar Sun>=1 2:00 0
S
Rule NZ 1928 only - Nov 4 2:00 0:30
HD
Rule NZ 1929 only - Oct 30 2:00 0:30
HD
Rule NZ 1930 1933 - Mar Sun>=15 2:00 0
S
Rule NZ 1930 1933 - Oct Sun>=8 2:00 0:30
HD
Rule NZ 1934 1940 - Apr lastSun 2:00 0
S
Rule NZ 1934 1939 - Sep lastSun 2:00 0:30
HD
Rule NZ 1974 only - Nov 3 2:00s 1:00
D
Rule NZ 1975 1988 - Oct lastSun 2:00s 1:00
D
Rule NZ 1989 only - Oct 8 2:00s 1:00
D
Rule NZ 1990 2006 - Oct Sun>=1 2:00s 1:00
D
Rule NZ 2007 max - Sep lastSun 2:00s 1:00
D
Rule NZ 1975 only - Feb 23 2:00s 0
S
Rule NZ 1976 1989 - Mar Sun>=1 2:00s 0
S
Rule NZ 1990 2007 - Mar Sun>=15 2:00s 0
S
Rule NZ 2008 max - Apr Sun>=1 2:00s 0
S
Zone Pacific/Auckland 11:39:04 - LMT 1868
11:30 NZ NZ%sT 1940 Sep 29 2:00
12:00 NZ NZ%sT
#
Compile it with 'zic'
# zic NZ.zi
Assuming that you are configured to use NZST/NZDT at the moment, and if
/etc/localtime isn't a link back to
/usr/share/zoneinfo/Pacific/Auckland, update it with the new one:
# cp /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
cp: overwrite `/etc/localtime'? y
And you are done.
You will want to test it, so I have a little 'C' test program that might
help - when run it test critical dates/times (but only those in the
future!). You could do it in a few lines of Perl, but....
# gcc -o tztest tztest.c; ./tztest
2007-09-30 01:59 NZST - passed
2007-09-30 03:00 NZDT - passed
2007-10-07 02:59 NZDT - passed
2007-10-07 03:00 NZDT - passed
2008-03-16 02:59 NZDT - passed
2008-03-16 03:00 NZDT - passed
2008-04-06 02:59 NZDT - passed
2008-04-06 02:00 NZST - passed
Timezone tests passed without error
#
------ snip here ------------------------------------------
/* tztest.c - test timezone changes */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <locale.h>
int PrintTime(time_t seconds, char *test) {
char buffer[128];
int count;
struct tm *broken_down;
memset(buffer,'A',sizeof(buffer));
broken_down = localtime(&seconds);
if(broken_down == NULL) {
fprintf(stderr,"localtime() failed\n");
exit(1);
}
count = strftime(buffer, sizeof(buffer)-1,
"%Y-%m-%d %H:%M %Z", broken_down);
if(count == 0 && buffer[0] == 'A') {
fprintf(stderr,"strftime() failed\n");
exit(1);
}
if(strcmp(buffer+strlen(buffer)-4, test)!= 0) {
printf("%s - FAILED - it should be %s\n",buffer,test);
return 1;
}
printf("%s - passed\n",buffer);
return 0;
}
int main(int c, char *v[])
{
int count = 0;
time_t seconds = 1191074340; /* Just before NZST 2007 */
if(PrintTime(seconds,"NZST")) count++;
if(PrintTime(seconds+60,"NZDT")) count++;
if(PrintTime(seconds+7*3600*24,"NZDT")) count++;
if(PrintTime(seconds+7*3600*24+60,"NZDT")) count++;
if(PrintTime(seconds+168*3600*24,"NZDT")) count++;
if(PrintTime(seconds+168*3600*24+60,"NZDT")) count++;
if(PrintTime(seconds+189*3600*24,"NZDT")) count++;
if(PrintTime(seconds+189*3600*24+60,"NZST")) count++;
if(count != 0)
{
printf("==========================================\n");
printf("TEST FAILED - System Timezone has %i errors\n",count);
printf("==========================================\n");
}
else
{
printf("\n\nTimezone tests passed without error\n");
}
return 0;
}
------ end snip here ------------------------------------------
-----Original Message-----
From: nzlug-bounces at linux.net.nz [mailto:nzlug-bounces at linux.net.nz] On
Behalf Of ronw at paradise.net.nz
Sent: Wednesday, 15 August 2007 9:51 a.m.
To: NZLUG Mailing List
Subject: [nzlug] Daylight Saving
I am just starting to read up on changes for the new NZDST. I note that
Redhat
seems to have it covered except for Evolution which they basically say
live with
the wrong time for three weeks??? but what about other major Linux
distros. Are
there any caveats?
The pain is bad enough if you run Exchange but at least MS do have a
work around.
-
Ron Wilson
_______________________________________________
NZLUG mailing list NZLUG at linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Computer Concepts Limited
25 Leslie Hills Drive
PO Box 8744 Riccarton
Christchurch, New Zealand
Phone: +64-3-348-2500
Fax: +64-3-343-7569
Notice of confidential information:
The information contained in this e-mail message is
confidential information and may also be legally privileged,
intended only for the individual or entity named above.
If you are not the intended recipient you are hereby
notified that any use, review, dissemination, distribution
or copying of this document is strictly prohibited.
If you have received this document in error, please
immediately notify the sender by telephone and destroy the
message. Thank you.
All prices quoted in this email are exclusive of GST & Freight and
valid only while stocks last.
More information about the NZLUG
mailing list