Could anyone help

Bradley White bww at acm.org
Wed Dec 29 15:48:02 UTC 1999


> I'd like to produce a list of all the distict beginnings of the new
> millenium - listing the zone and UTC time when they will first see the new
> millenium, e.g.:
> 
> Pacific/Chatham Island     Dec 31  10:15 UTC
> ....
> Europe/Paris Dec 31 23:00 UTC
> Europe/London Jan 1 00:00 UTC
> ...
> etc..
> 
> I'd be really grateful if anyone can help with this, or alternatively point
> me to a list that already exists on the web somewhere.

#!/usr/bin/env perl

use integer;
use strict;
use POSIX qw(mktime strftime tzset);

# set $tzdir and $bogon as you see fit
my $tzdir = '/usr/share/zoneinfo';
my $bogon = '^(right|posix|Etc|SystemV)/|\.tab$'
	  .'|^(Factory|UTC|localtime)$|^GMT.'
	  .'|^(..T|.ST\d.DT)$';

my %mill = ();
chdir $tzdir or die "$tzdir: $!\n";
foreach my $zone (`find * -type f -print`) {
    chomp $zone;  next if $zone =~ m:$bogon:o;
    $ENV{'TZ'} = $zone;  tzset;
    my $when = mktime(0, 0, 0, 1, 0, 2000-1900);
    $mill{$when} = [] unless exists $mill{$when};
    push @{$mill{$when}}, $zone;
}
foreach my $when (sort { $a <=> $b } keys %mill) {
    my %zones = ();
    foreach my $zone (@{$mill{$when}}) {
	my ($dev, $ino) = stat $zone;
	next unless defined $ino;
	$zones{"$dev.$ino"} = [] unless exists $zones{"$dev.$ino"};
	push @{$zones{"$dev.$ino"}}, $zone;
    }
    print strftime "%b %d %H:%M UTC\n", gmtime $when;
    foreach my $devino (keys %zones) {
	print ' 'x4, join('|', sort @{$zones{$devino}}), "\n";
    }
}

exit 0;



More information about the tz mailing list