File Coverage

lib/Net/ICal/VTIMEZONES.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition 1 2 50.0
subroutine 4 4 100.0
pod 1 1 100.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Net::ICal::VTIMEZONES;
2              
3 1     1   26563 use vars qw($timezones);
  1         2  
  1         63  
4              
5             BEGIN {
6 1     1   415 use Net::ICal::Config;
  1         4  
  1         167  
7 1   50 1   6 my $zonedir = $Net::ICal::Config->{'zoneinfo_location'} || "zoneinfo";
8              
9             # I have no idea what the first two fields in this file mean, but
10             # the third one is all Olsen timezone names.
11 1         3 my $zonefile = "$zonedir/zones.tab";
12              
13 1 50       63 open(ZONEFILE, $zonefile)
14             or die ("Couldn't open timezone info file $zonefile");
15              
16 1         37 while () {
17 377         1023 my @fields = split(' ', $_);
18 377         463 my $zonename = $fields[2];
19 377         904 $timezones->{$zonename} = {};
20 377         1825 $timezones->{$zonename}->{'file'} = "$zonedir/$zonename.ics";
21             }
22             }
23              
24             =head1 NAME
25              
26             Date::ICal - Perl extension for ICalendar date objects.
27              
28             =head1 SYNOPSIS
29              
30             my $zones = Net::ICal::VTIMEZONES::timezones;
31              
32             # a list of all the zones
33             @zonenames = keys %{$timezones};
34              
35             # to get a file to load VTIMEZONE data from
36             $zonefile = $zones->{'America/Bogota'}->{'file'};
37            
38             =head1 METHODS
39              
40             =head2 timezones
41              
42             Returns a hashref of hashrefs; the hashref's keys are names of
43             timezones. Each timezone hash has one element at present, "file",
44             which is the file where you can get VTIMEZONE information
45             for this timezone.
46              
47             =cut
48              
49             sub timezones {
50 1     1 1 8 return $timezones;
51             }
52              
53             1;
54             __END__