| 1 | package XML::Feed::Util; | ||||||||||||||||||||||||||||||||||
| 2 | 35 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | 35 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 35 | our $VERSION = '1.0.1'; | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 35 | ▶ | use base qw( Exporter ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 35 | ▶ | use DateTime::Format::Flexible; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 35 | ▶ | use DateTime::Format::ISO8601; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 35 | ▶ | use DateTime::Format::Natural; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 35 | ▶ | use DateTime::Format::W3CDTF; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 35 | ▶ | use DateTime::Format::Mail; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 35 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||
| 15 | format_w3cdtf | ||||||||||||||||||||||||||||||||||
| 16 | parse_datetime | ||||||||||||||||||||||||||||||||||
| 17 | parse_w3cdtf_date | ||||||||||||||||||||||||||||||||||
| 18 | parse_mail_date | ||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 10 | ▶ | sub format_w3cdtf { | ||||||||||||||||||||||||||||||||
|
Subroutine
format_w3cdtf: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 22 | 10 | my $dt = shift; | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 10 | my $date = DateTime::Format::W3CDTF->format_datetime($dt); | |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | # Add timezone "Z" if "floating" DateTime. | ||||||||||||||||||||||||||||||||||
| 27 | 10 | ▶ | $date .= 'Z' if $dt->time_zone->is_floating; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 10 | return $date; | |||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 19 | ▶ | sub parse_datetime { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_datetime: called CC=5 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 33 | 19 | ▶ | my $ts = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 16 | $ts = _strip_spaces($ts); | |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 16 | return eval { DateTime::Format::ISO8601->parse_datetime($ts) } | |||||||||||||||||||||||||||||||||
| 38 | 0 | || eval { DateTime::Format::Flexible->parse_datetime($ts) } | |||||||||||||||||||||||||||||||||
| 39 | 16 | ▶ | || do { | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
eval {
do {
'DateTime::Format::ISO8601'->parse_datetime($ts)
}
} || eval {
do {
'DateTime::Format::Flexible'->parse_datetime($ts)
}
} || do {
my $p = 'DateTime::Format::Natural'->new;
my $dt = $p->parse_datetime($ts);
$p->success ? $dt : undef
}
eval {
do {
"DateTime::Format::ISO8601"->parse_datetime($ts)
}
} or eval {
do {
"DateTime::Format::Flexible"->parse_datetime($ts)
}
}
MC/DC0%0/3
eval {
do {
'DateTime::Format::ISO8601'->parse_datetime($ts)
}
} || eval {
do {
'DateTime::Format::Flexible'->parse_datetime($ts)
}
} || do {
my $p = 'DateTime::Format::Natural'->new;
my $dt = $p->parse_datetime($ts);
$p->success ? $dt : undef
}
eval {
do {
"DateTime::Format::ISO8601"->parse_datetime($ts)
}
}
eval {
do {
"DateTime::Format::Flexible"->parse_datetime($ts)
}
}
do {
my $p = 'DateTime::Format::Natural'->new;
my $dt = $p->parse_datetime($ts);
$p->success ? $dt : undef
}
Truth table25%1/4
A or B || C
A= eval {
do {
"DateTime::Format::ISO8601"->parse_datetime($ts)
}
}B= eval {
do {
"DateTime::Format::Flexible"->parse_datetime($ts)
}
}C= do {
my $p = 'DateTime::Format::Natural'->new;
my $dt = $p->parse_datetime($ts);
$p->success ? $dt : undef
}
| |||||||||||||||||||||||||||||||||||
| 40 | 0 | my $p = DateTime::Format::Natural->new; | |||||||||||||||||||||||||||||||||
| 41 | 0 | my $dt = $p->parse_datetime($ts); | |||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $p->success ? $dt : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub parse_mail_date { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_mail_date: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $ts = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 0 | $ts = _strip_spaces($ts); | |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return eval { DateTime::Format::Mail->new(loose => 1)->parse_datetime($ts) } | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
'DateTime::Format::Mail'->new('loose', 1)->parse_datetime($ts)
}
} || parse_datetime($ts)
MC/DC0%0/2
eval {
do {
'DateTime::Format::Mail'->new('loose', 1)->parse_datetime($ts)
}
} || parse_datetime($ts)
eval {
do {
'DateTime::Format::Mail'->new('loose', 1)->parse_datetime($ts)
}
}
parse_datetime($ts)
Truth table0%0/3
A || B
A= eval {
do {
'DateTime::Format::Mail'->new('loose', 1)->parse_datetime($ts)
}
}B= parse_datetime($ts)
| |||||||||||||||||||||||||||||||||||
| 52 | || parse_datetime($ts); | ||||||||||||||||||||||||||||||||||
| 53 | }; | ||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub parse_w3cdtf_date { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_w3cdtf_date: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $ts = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | 0 | $ts = _strip_spaces($ts); | |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return eval { DateTime::Format::W3CDTF->parse_datetime($ts) } | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
'DateTime::Format::W3CDTF'->parse_datetime($ts)
}
} || parse_datetime($ts)
MC/DC0%0/2
eval {
do {
'DateTime::Format::W3CDTF'->parse_datetime($ts)
}
} || parse_datetime($ts)
eval {
do {
'DateTime::Format::W3CDTF'->parse_datetime($ts)
}
}
parse_datetime($ts)
Truth table0%0/3
A || B
A= eval {
do {
'DateTime::Format::W3CDTF'->parse_datetime($ts)
}
}B= parse_datetime($ts)
| |||||||||||||||||||||||||||||||||||
| 61 | || parse_datetime($ts); | ||||||||||||||||||||||||||||||||||
| 62 | }; | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 16 | ▶ | sub _strip_spaces { | ||||||||||||||||||||||||||||||||
|
Subroutine
_strip_spaces: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||
| 65 | 16 | local $_ = shift; | |||||||||||||||||||||||||||||||||
| 66 | 16 | ▶ | s/^\s+//, s/\s+$// if $_; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 67 | 16 | return $_; | |||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 35 | 1; | |||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||