blib/lib/DateTime/Format/Strftimeq.pm

filter: Statementstmt 90.6% 29 / 32 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 88.0% 44 / 50 CC 6 SCAR 11.3
CC
6
Cov
86%
new
5.2
format_datetime
2.1
BEGIN
1.0
CRAP 3.1
↑ Summary
1 package DateTime::Format::Strftimeq;
2  
3 2 our $DATE = '2019-11-19'; # DATE
4 2 our $DIST = 'DateTime-Format-Strftimeq'; # DIST
5 2 our $VERSION = '0.001'; # VERSION
6  
7 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use DateTimeX::strftimeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶sub new {
Subroutine new: called CC=5 SCAR=16.4
Pod documented
14 3 my ($class, %args) = @_;
15  
16 3 my $self = {};
17  
18 3 ▶ if (defined(my $time_zone = delete $args{time_zone})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $time_zone = delete $args{"time_zone"})) 1 2 3
19 1 $self->{time_zone} = do {
20 1 ▶ if (ref $time_zone) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $time_zone) { } 0 1 1
21 0 $time_zone;
22 } else {
23 1 require DateTime::TimeZone;
24 1 DateTime::TimeZone->new(name => $time_zone);
25 }
26 };
27 }
28  
29 2 $self->{format} = delete $args{format};
30 2 ▶ defined $self->{format} or die "Please specify 'format'";
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"format"} or die "Please specify 'format'" 1 1 2
31  
32 1 ▶ if (keys %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %args) 0 1 1
33 0 die "Unknown attribute(s): ".join(", ", sort keys %args);
34 }
35  
36 1 bless $self, $class;
37 }
38  
39 2 ▶sub format_datetime {
Subroutine format_datetime: called CC=2 SCAR=7.6
Pod documented
40 2 my ($self, $dt) = @_;
41  
42 2 ▶ if ($self->{time_zone}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"time_zone"}) 0 2 2
43 0 $dt = $dt->clone->set_time_zone($self->{time_zone});
44 }
45  
46 2 strftimeq($self->{format}, $dt);
47 }
48  
49 2 1;
50 # ABSTRACT: Format DateTime object using DateTimeX::strftimeq
51  
52 __END__
↑ Summary