DateTime::TimeZone::Catalog - Provides a list of all valid time zone names
See DateTime::TimeZone for API details.
This module contains an enumerated list of all known system timezones, so that applications can easily present a list of timezones.
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
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.
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); }
To install DateTime::TimeZone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DateTime::TimeZone
CPAN shell
perl -MCPAN -e shell install DateTime::TimeZone
For more information on module installation, please visit the detailed CPAN module installation guide.