The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DateTime::TimeZone::Catalog - Provides a list of all valid time zone names

DESCRIPTION

This module contains an enumerated list of all known system timezones, so that applications can easily present a list of timezones.

AVAILABLE ZONES

Zones by Continent/Region

EOF

    for my $category ( sort keys %categories ) {
        $zonecatalog .= "=head3 $category\n\n";

        for my $zone ( @{ $categories{$category} } ) {
            $zonecatalog .= "  $category/$zone\n";
        }

        $zonecatalog .= "\n";
    }

    $zonecatalog .= <<'EOF';
=head2 Zones by Country

EOF

    for my $country (
        sort { lc $a->[0] cmp lc $b->[0] }
        map {
            my $country = my_code2country($_);
            warn "no country for $_\n" unless defined $country;
            [ $country, $_ ];
        } grep { $_ ne 'UK' } keys %countries
        ) {

        $zonecatalog .= "=head3 $country->[0] ($country->[1])\n\n";

        for my $zone ( @{ $countries{ $country->[1] } } ) {
            my $line = join ' - ', grep {defined} @{$zone};
            $zonecatalog .= "  $line\n";
        }

        $zonecatalog .= "\n";
    }

    $zonecatalog .= <<'EOF';
=head2 Linked Zones

A linked zone is an alias from one name to another.

EOF

    for my $from ( sort keys %links ) {
        $zonecatalog .= "  $from => $links{$from}\n";
    }

    $zonecatalog .= "\n";

    $zonecatalog .= "=cut\n";

    open my $fh, ">lib/DateTime/TimeZone/Catalog.pm" or die $!;
    print $fh $zonecatalog or die $!;
    close $fh or die $!;
}

sub parse_zone_tab { my $file = File::Spec->catfile( $opts{dir}, 'zone.tab' );

    open my $fh, "<$file" or die "Cannot read $file: $!";

    my %countries;
    while (<$fh>) {
        next if /^\#/;
        chomp;

        my ( $cc, undef, $tz, $desc ) = split /\t+/, $_;

        push @{ $countries{$cc} }, [ $tz, $desc ];
    }

    return %countries;
}

sub my_code2country { my $code = shift;

    return 'South Sudan' if $code eq 'SS';

    return code2country($code);
}