blib/lib/Astro/App/Satpass2/FormatTime/POSIX/Strftime.pm

filter: Statementstmt 87.0% 47 / 54 Branchbran 66.6% 8 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 14 / 16 Podpod 100% 1 / 1 totaltotal 79.5% 70 / 88 CC 8 SCAR 14.1
CC
8
Cov
80%
format_datetime
10.5
__ANON__
2.0
__ANON__
2.0
CRAP 4.1
« blib/lib/Astro/App/Satpass2/FormatTime/DateTime/Cldr.pm ↑ Summary blib/lib/Astro/App/Satpass2/Warner.pm »
1 package Astro::App::Satpass2::FormatTime::POSIX::Strftime;
2  
3 20 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 20 ▶use parent qw{ Astro::App::Satpass2::FormatTime };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 20 ▶use Astro::Coord::ECI::Utils qw{ gm_strftime local_strftime };
Subroutine BEGIN: called CC=1 SCAR=0.0
11 20 ▶use Astro::App::Satpass2::FormatTime::Strftime;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 ▶use Astro::App::Satpass2::Utils qw{ ARRAY_REF @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
13 20 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 20 our $VERSION = '0.059';
16  
17 618 ▶sub format_datetime {
Subroutine format_datetime: called CC=7 SCAR=23.6
Pod documented
18 618 my ( $self, $tplt, $time, $gmt ) = @_;
19 618 $time = $self->__round_time_value( $time );
20 618 ▶ defined $gmt or $gmt = $self->gmt();
Branch: 1 branch
BranchTrueFalseTotal
defined $gmt or $gmt = $self->gmt 8 610 618
21 618 ▶ if ( ARRAY_REF eq ref $time ) {
Branch: 2 branches
BranchTrueFalseTotal
if ('ARRAY' eq ref $time) { } 330 288 618
elsif ($gmt) { } 288 0 288
22 # NOTE that this is not documented, and is used only to
23 # determine the maximum width generated by the given time
24 # format, so I believe it can stand as-is. IF this is wrong AND
25 # the strftime() behavior of Perl 5.39.8 and 5.39.9 makes it int
26 # 5.40, I will need to set the zone to 'GMT' if $gmt is true.
27 $gmt
28 330 ▶ and local $ENV{TZ} = 'GMT';
Branch: 1 branch
BranchTrueFalseTotal
$gmt and local $ENV{"TZ"} = "GMT" 330 0 330
29 330 return POSIX::strftime( $tplt, @{ $time } );
30 } elsif ( $gmt ) {
31 288 return gm_strftime( $tplt, $time );
32 } else {
33 0 my $tz = $self->tz();
34 defined $tz
35 and $tz ne ''
36 0 ▶ and local $ENV{TZ} = $tz;
Branch: 1 branch
BranchTrueFalseTotal
defined $tz and $tz ne "" and local $ENV{"TZ"} = $tz 0 0 0
Condition0%0/3
defined $tz and $tz ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tz and $tz ne ""
defined $tz $tz ne ""
Truth table0%0/3
A and B
A= defined $tzB= $tz ne ""
ABresult
0X0
100
111
37 0 return local_strftime( $tplt, $time );
38 }
39 }
40  
41 {
42 my %adjuster = (
43 30 ▶ year => sub { $_[0][5] = $_[1] - 1900; return },
Subroutine __ANON__: called CC=1 SCAR=0.0
44 195 ▶ month => sub { $_[0][4] = $_[1] - 1; return },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 120 ▶ day => sub { $_[0][3] = $_[1]; return },
Subroutine __ANON__: called CC=1 SCAR=0.0
46 45 ▶ hour => sub { $_[0][2] = $_[1]; return },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 0 ▶ minute => sub { $_[0][1] = $_[1]; return },
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 ▶ second => sub { $_[0][0] = $_[1]; return },
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 20 );
50  
51 390 ▶ sub __format_datetime_width_adjust_object {
Subroutine __format_datetime_width_adjust_object: called CC=2 SCAR=6.9
52 390 my ( undef, $obj, $name, $val ) = @_; # Invocant unused
53 390 ▶ $obj or $obj = [ 0, 0, 0, 1, 0, 200 ];
Branch: 1 branch
BranchTrueFalseTotal
$obj or $obj = [0, 0, 0, 1, 0, 200] 375 15 390
54 390 $adjuster{$name}->( $obj, $val );
55 390 return $obj;
56 }
57  
58 }
59  
60 20 1;
61  
62 __END__
« blib/lib/Astro/App/Satpass2/FormatTime/DateTime/Cldr.pm ↑ Summary blib/lib/Astro/App/Satpass2/Warner.pm »