| 1 | # $Id: /mirror/perl/DateTime-Format-RSS/trunk/lib/DateTime/Format/RSS.pm 63379 2008-06-17T20:51:20.618065Z daisuke $ | ||||||||||||
| 2 | # | ||||||||||||
| 3 | # Copyright (c) 2006 Daisuke Maki <dmaki@cpan.org> | ||||||||||||
| 4 | # All rights reserved. | ||||||||||||
| 5 | |||||||||||||
| 6 | package DateTime::Format::RSS; | ||||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | ▶ | use vars qw($VERSION); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 3 | ▶ | use DateTime::Format::Mail; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 3 | ▶ | use DateTime::Format::ISO8601; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 3 | ▶ | use DateTime::Format::DateParse; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 3 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 3 | __PACKAGE__->mk_accessors($_) for qw(parsers version); | |||||||||||
| 16 | |||||||||||||
| 17 | BEGIN | ||||||||||||
| 18 | 3 | ▶ | { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 3 | $VERSION = '0.03000'; | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | sub new | ||||||||||||
| 23 | 3 | ▶ | { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 24 | 3 | my $class = shift; | |||||||||||
| 25 | 3 | my %args = @_; | |||||||||||
| 26 | my $self = $class->SUPER::new({ | ||||||||||||
| 27 | 3 | ▶ | version => $args{version} || '1.0', | ||||||||||
|
Condition100%2/2
$args{'version'} || '1.0'
MC/DC100%1/1
$args{'version'} || '1.0'
$args{'version'}
Truth table100%2/2
A
A= $args{'version'}
| |||||||||||||
| 28 | parsers => [ | ||||||||||||
| 29 | # order matters | ||||||||||||
| 30 | DateTime::Format::Mail->new, | ||||||||||||
| 31 | DateTime::Format::ISO8601->new, | ||||||||||||
| 32 | 'DateTime::Format::DateParse', | ||||||||||||
| 33 | ] | ||||||||||||
| 34 | }); | ||||||||||||
| 35 | 3 | return $self; | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | sub parse_datetime | ||||||||||||
| 39 | 123 | ▶ | { | ||||||||||
|
Subroutine
parse_datetime: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||
| 40 | 123 | my $self = shift; | |||||||||||
| 41 | 123 | my $date = shift; | |||||||||||
| 42 | 123 | ▶ | if (! ref($self)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 0 | $self = $self->new(); | |||||||||||
| 44 | } | ||||||||||||
| 45 | |||||||||||||
| 46 | 123 | my $dt; | |||||||||||
| 47 | 123 | foreach my $p (@{$self->parsers}) { | |||||||||||
| 48 | 195 | $dt = eval { $p->parse_datetime($date) }; | |||||||||||
| 49 | 195 | ▶ | last if $dt; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 50 | } | ||||||||||||
| 51 | 123 | return $dt; | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | sub format_datetime | ||||||||||||
| 55 | 2 | ▶ | { | ||||||||||
|
Subroutine
format_datetime: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 56 | 2 | my $self = shift; | |||||||||||
| 57 | 2 | ▶ | if ($self->version eq '2.0') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 58 | 1 | return $self->parsers->[0]->format_datetime($_[0]); | |||||||||||
| 59 | } else { | ||||||||||||
| 60 | 1 | return $_[0]->iso8601; | |||||||||||
| 61 | } | ||||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 3 | 1; | |||||||||||
| 65 | |||||||||||||
| 66 | __END__ | ||||||||||||