Could anyone help

Bradley White bww at acm.org
Wed Dec 29 16:12:49 UTC 1999


Oops ... I forgot to account for daylight savings in the call to
mktime.  Sorry about that.

#!/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|posixrules)$'
	  .'|^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, 0, 0, -1);
    $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