gabriel rosenkoetter on 6 Mar 2007 00:50:07 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Daylight Savings Time


Call me late to the party, but I just noticed that one of my
Important Systems (embarassingly out of date in other ways too,
never mind running out of more than one tower case at the moment...
you really don't want to know) is done broke for 2k7 US DST standards:

% perl -MPOSIX -e '@now = localtime(time()); 
	print strftime("%c", @now), "\n";'
Mon Mar  5 19:05:33 2007
% perl -MPOSIX -e '@now = localtime(time() + 604800); 
	print strftime("%c", @now), "\n";'
Mon Mar 12 19:05:35 2007

(Incidentally, if your local date(1), like mine on {Net,Free}BSD
isn't GNU and, thus, doesn't do --date, that's the Perl slacker way
to do the same thing. Yeah, sure, I could have forcibly typed
localtime()'s output to an array, but I always forget the syntax for
that without trying it at least twice.)

Fortunately, I'd noted Stephen's concise "here's how you get the
current tzdata in a POSIX way, screw package systems" post from a
month ago, partially quoted below.

On Fri, Feb 02, 2007 at 05:10:54PM +0000, Stephen Gran wrote:
> You'll need to update your zoneinfo file (mine is
> /usr/share/zoneinfo/Europe/London, yours will probably be
> America/NewYork or something).  You can download new zoneinfo data from
> here:
> ftp://elsie.nci.nih.gov/pub/tzsource*.tar.gz

Only but tzsource*.tar.gz doesn't match anything any more.
ftp://elsie.nci.nih.gov/pub/ looks like this at the moment:

ftp> ls
500 'EPSV': command not understood.
227 Entering Passive Mode (137,187,215,78,161,152)
150 Opening ASCII mode data connection for /bin/ls.
total 30734
drwxr-xr-x   2 8800     3            512 Feb 26 14:11 .
dr-xr-xr-x   5 8800     1            512 May  6  2002 ..
-r--r--r--   1 8800     10         50176 Apr 24  1997 leastsq.xls
-rw-r--r--   1 8800     0         180806 Feb 20  2006 old-tzcode-32-bit-output.tar.gz
-r--r--r--   1 8800     0           3073 Mar  9  1994 pi.shar.gz
-rw-r--r--   1 8800     0        15096249 Mar  5 18:17 tzarchive.gz
-rw-r--r--   1 8800     0         189109 Feb 26 14:09 tzcode2007c.tar.gz
-rw-r--r--   1 8800     0         158198 Feb 26 14:09 tzdata2007c.tar.gz
226 Transfer complete.

You (or, really, I, since presumably the rest of you weren't quite
so lazy about this... I'm trying to avoid doing this on my 2006
*taxes*, just for the record) want tzdata2007c.tar.gz.

This tarball expands into the current working directory, rather than
into a tzsource subdirectory, so make your own, mv(1) the tarball
there, and then the rest, less changing the arguments to tar(1) below
in the obvious ways, is as Stephen stated:

> And you can build new zone files with:
> 
> mkdir -p tzgen/{posix,right}
> tar -xzf tzsource*.tar.gz
> for zone in africa antarctica asia australasia europe northamerica southamerica etcetera factory solar87 solar88 solar89 backward systemv ; do 
>   /usr/sbin/zic -d tzgen -L /dev/null -y tzsource/yearistype.sh tzsource/${zone} 
>   /usr/sbin/zic -d tzgen/posix -L /dev/null -y tzsource/yearistype.sh tzsource/${zone} 
>   /usr/sbin/zic -d tzgen/right -L tzsource/leapseconds -y tzgen/yearistype.sh tzsource/${zone} 

... EXCEPT FOR THIS TYPO.

That should be "-y tzsource/yearistype.sh". Tab completion's a bitch
some times, Stephen. ;^>

> done
> 
> The resulting files need to be installed to wherever your distro keeps
> zoneinfo files, presumably also /usr/share/zoneinfo .

And, voila:

% pwd
/home/gr/TZ_update-20070305/tzgen/right
% sudo pax -r -w -v . /usr/share/zoneinfo
[lots of crap]
% perl -MPOSIX -e '@now = localtime(time());
  print strftime("%c", @now), "\n";'
Mon Mar  5 19:46:13 2007
% perl -MPOSIX -e '@now = localtime(time() + 604800);
  print strftime("%c", @now), "\n";'
Mon Mar 12 20:46:18 2007

Note also that, maybe Linux does, but NetBSD does not[1] do the whole
/usr/share/zoneinfo/posix and /usr/share/zoneinfo/right thing. You
probably actually want the tree under tzgen/right (I normally
support POSIX as Right, but the math was simply wrong here, and
you'll actually want those leap seconds, at least in theory).

Or, alternately, and I did very seriously consider this, just set
your host's time to UTC and forget this BS forever. (I did seriously
consider this... it's only `ln -s -f /usr/share/zoneinfo/UTC
/etc/localtime` on most POSIX-y systems. I mean, sure, then your
system's date is always UTC, and off by four or five hours for those
of us living in Eastern, depending on the month of the year, but
most uses of strftime(3)--notably NOT its %c, idiotically--will
tell you so if you ask. And, really, if you work for a multi-national
at this point, dealing with time zones is almost more effort than
it's worth. All the cool kids may just be living by UTC within the
next decade.)

Hope this helps at least one person, but I figure I'm the last to
get around to it. (And two weeks after we got around to it at work...
even including all the frickin' Java installations!!!)

Cheers...

-- 
gabriel rosenkoetter
gr@eclipsed.net

[1] I'm pretty sure that NetBSD installs the "right" under
/usr/share/zoneinfo, and somehow mashes all the "posix" versions
into a single TZ data file at /usr/share/zoneinfo/posixrules... but
I've already wasted too much of my life on this, so I'm not digging
any deeper.

Attachment: pgp2mVRFLDcPa.pgp
Description: PGP signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug