File Coverage

blib/lib/Rose/DateTime/Parser.pm
Criterion Covered Total %
statement 31 35 88.5
branch 12 14 85.7
condition n/a
subroutine 9 9 100.0
pod 3 5 60.0
total 55 63 87.3


line stmt bran cond sub pod time code
1             package Rose::DateTime::Parser;
2              
3 1     1   1792 use strict;
  1         2  
  1         36  
4              
5 1     1   5 use Rose::DateTime::Util();
  1         2  
  1         14  
6              
7 1     1   774 use Rose::Object;
  1         142  
  1         49  
8             our @ISA = qw(Rose::Object);
9              
10             use Rose::Object::MakeMethods::Generic
11             (
12 1         15 scalar => 'error',
13             'scalar --get_set_init' => 'time_zone',
14 1     1   1670 );
  1         11164  
15              
16             our $VERSION = '0.50';
17              
18 1     1 0 11302 sub init_time_zone { Rose::DateTime::Util->time_zone }
19 3     3 0 13 sub init_european { Rose::DateTime::Util->european_dates }
20              
21             sub european
22             {
23 12     12 1 1084 my($self) = shift;
24              
25 12 100       32 if(@_)
26             {
27 3 100       7 if(defined $_[0])
28             {
29 2 100       9 return $self->{'european'} = $_[0] ? 1 : 0;
30             }
31 1         3 else { $self->{'european'} = undef }
32             }
33              
34 10 100       36 return $self->{'european'} if(defined $self->{'european'});
35 3         8 $self->{'european'} = $self->init_european;
36             }
37              
38             sub parse_date
39             {
40 7     7 1 398 my($self) = shift;
41              
42 7         8 my $date;
43              
44 7 100       38 if($self->european)
45             {
46 3         11 $date = Rose::DateTime::Util::parse_european_date(shift, $self->time_zone);
47             }
48             else
49             {
50 4         6 local $Rose::DateTime::Util::European_Dates = 0;
51 4         13 $date = Rose::DateTime::Util::parse_date(shift, $self->time_zone);
52             }
53              
54 7 50       19 return $date if($date);
55 0         0 $self->error(Rose::DateTime::Util->error);
56 0         0 return $date;
57             }
58              
59             *parse_datetime = \&parse_date;
60              
61             sub parse_european_date
62             {
63 1     1 1 335 my($self) = shift;
64 1         5 my $date = Rose::DateTime::Util::parse_european_date(shift, $self->time_zone);
65 1 50       43 return $date if($date);
66 0           $self->error(Rose::DateTime::Util->error);
67 0           return $date;
68             }
69              
70             1;
71              
72             __END__