blib/lib/LibUI/Time.pm

filter: Statementstmt 68.9% 20 / 29 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod n/a totaltotal 58.7% 27 / 46 CC 5 SCAR 20.3
CC
5
Cov
54%
to_hash
20.0
to_obj
6.0
BEGIN
1.0
CRAP 7.6
↑ Summary blib/lib/LibUI/Menu.pm »
1 package LibUI::Time 0.01 {
2 1 ▶ use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶ use Affix;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ use Time::Local 1.30 qw[timelocal_posix];
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ use Time::Piece;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 #
10 our $COERCE = 1; # Set to false to get the raw LibUI::Time structures in pickers
11  
12 #
13 typedef 'LibUI::Time' => Struct [
14 tm_sec => Int,
15 tm_min => Int,
16 tm_hour => Int,
17 tm_mday => Int,
18 tm_mon => Int,
19 tm_year => Int,
20 tm_wday => Int,
21 tm_yday => Int,
22 tm_isdst => Int,
23  
24 # BSD and GNU extension; not defined in a strict ISO C env
25 ( $Config{d_tm_tm_gmtoff} ? ( tm_gmtoff => Long, ) : () ),
26 ( $Config{d_tm_tm_zone} ? ( tm_zone => Str ) : () )
27 ];
28  
29 sub to_obj($) {
30 0 ▶ my $s = shift;
Subroutine to_obj: not called CC=2 SCAR=17.9
31 0 ▶ if ($COERCE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LibUI::Time::COERCE) 0 0 0
32 my $t = Time::Piece->_mktime(
33 timelocal_posix(
34 $s->{tm_sec}, $s->{tm_min}, $s->{tm_hour},
35 $s->{tm_mday}, $s->{tm_mon}, $s->{tm_year}
36 )
37 0 );
38 0 return $t;
39 }
40 0 return $s;
41 }
42  
43 sub to_hash($) {
44 0 ▶ my $s = shift;
Subroutine to_hash: not called CC=4 SCAR=30.0
45 0 ▶ if ( ref $s eq 'Time::Piece' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $s eq "Time::Piece") 0 0 0
46 return {
47 tm_sec => $s->sec,
48 tm_min => $s->min,
49 tm_hour => $s->hour,
50 tm_mday => $s->mday,
51 tm_mon => $s->_mon,
52 tm_year => $s->_year,
53 tm_wday => $s->_wday,
54 tm_yday => $s->yday,
55 tm_isdst => $s->isdst,
56  
57 # BSD and GNU extension; not defined in a strict ISO C env
58 ( $Config{d_tm_tm_gmtoff} ? ( tm_gmtoff => int $s->tzoffset, ) : () ),
59 0 ▶ ( $Config{d_tm_tm_zone} ? ( tm_zone => 'GMT' ) : () )
Branch: 2 branches
BranchTrueFalseTotal
$LibUI::Time::Config{'d_tm_tm_gmtoff'} ? : 0 0 0
$LibUI::Time::Config{'d_tm_tm_zone'} ? : 0 0 0
60 };
61 }
62 0 $s;
63 }
64 }
65 1;
66 #
67 __END__
↑ Summary blib/lib/LibUI/Menu.pm »