Transform/Functions.pm

filter: Statementstmt 21.1% 46 / 218 Branchbran 17.3% 9 / 52 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 5 totaltotal 22.3% 64 / 287 CC 27 SCAR 46.0
CC
27
Cov
20%
bh_to_strftime_m
182.0
B_to_strftime_m
107.7
iI_p_to_strftime_H
3.1
CRAP 99.7
↑ Summary Transform.pm »
1 package Date::Transform::Functions;
2 ## SHOULD THIS BE ITS OWN PACKAGE SPACE
3 ## NO. These are not methods but functions.
4
5 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Switch 'Perl6';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 1 require Exporter;
13 1 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 our @ISA = qw( Exporter );
15
16 # Items to export into callers namespace by default. Note: do not export
17 # names by default without a very good reason. Use EXPORT_OK instead.
18 # Do not simply export all your public functions/methods/constants.
19
20 # This allows declaration use Date::Transform::Functions ':all';
21 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
22 # will save memory.
23
24 1 our %EXPORT_TAGS = (
25 'all' => [
26 qw(
27 iI_p_to_strftime_H
28 Y_to_strftime_y
29 bh_to_strftime_m
30 B_to_strftime_m
31 m_to_strftime_m
32 )
33 ]
34 );
35
36 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
37
38 1 our @EXPORT = qw(
39 iI_p_to_strftime_H
40 Y_to_strftime_y
41 bh_to_strftime_m
42 B_to_strftime_m
43 m_to_strftime_m
44 );
45
46 1 our $VERSION = '0.11';
47
48 # Preloaded methods go here.
49
50 ## This collection of functions changes provide the transformations of the
51 ## various formats.
52
53 ## SUBROUTINE: Ii_and_p_to_H
54 ## Transforms the hours and AM/PM to strftime H
55 ##
56 1 ▶sub iI_p_to_strftime_H {
Subroutine iI_p_to_strftime_H: called CC=3 SCAR=11.3
Pod undocumented
57
58 1 my $i = shift;
59 1 my $p = shift;
60
61 1 ▶ $i = 0 if ( $i == 12 );
Branch: 1 branch
BranchTrueFalseTotal
if $i == 12 0 1 1
62 1 ▶ $i += 12 if ( $p =~ /pm/i );
Branch: 1 branch
BranchTrueFalseTotal
if $p =~ /pm/i 1 0 1
63
64 1 return $i;
65
66 } # END SUBROUTINE: iI_p_to_strftime_H
67
68 ## SUBROUTINE: Y_to_strftime_y
69 ## Transform year(Y) to year(y) format.
70 0 ▶sub Y_to_strftime_y {
Subroutine Y_to_strftime_y: not called CC=1 SCAR=6.9
Pod undocumented
71
72 0 my $Y = shift;
73
74 0 return ( $Y - 1900 );
75
76 } # END SUBROUTINE: Y_to_strftime_y
77
78 ## SUBROUTINE: bh_to_strftime_m
79 ## Transforms month in b or h format to m format suitable for strftime input.
80 ##
81 0 ▶sub bh_to_strftime_m {
Subroutine bh_to_strftime_m: not called CC=13 SCAR=52.0
Pod undocumented
82
83 0 my $bh = shift;
84
85 0 given($bh) {
86
87 0 ▶ when /jan/i { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/jan/i)) 0 0 0
88 0 ▶ when /feb/i { return 1; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/feb/i)) 0 0 0
89 0 ▶ when /mar/i { return 2; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/mar/i)) 0 0 0
90 0 ▶ when /apr/i { return 3; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/apr/i)) 0 0 0
91 0 ▶ when /may/i { return 4; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/may/i)) 0 0 0
92 0 ▶ when /jun/i { return 5; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/jun/i)) 0 0 0
93 0 ▶ when /jul/i { return 6; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/jul/i)) 0 0 0
94 0 ▶ when /aug/i { return 7; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/aug/i)) 0 0 0
95 0 ▶ when /sep/i { return 8; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/sep/i)) 0 0 0
96 0 ▶ when /Oct/i { return 9; } # Note: Reserved keyword oct.
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/Oct/i)) 0 0 0
97 0 ▶ when /nov/i { return 10; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/nov/i)) 0 0 0
98 0 ▶ when /dec/i { return 11; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/dec/i)) 0 0 0
99
100 0 };
101
102 0 carp("Did not match a valid month.\n");
103
104 } # END SUBROUTINE: bh_to_strftime_m
105
106 ## SUBROUTINE: B_to_strftime_m
107 ## Transforms month from B format to m format suitable for
108 ## strftime input.
109 1 ▶sub B_to_strftime_m {
Subroutine B_to_strftime_m: called CC=13 SCAR=46.8
Pod undocumented
110
111 1 my $B = shift;
112
113 1 given($B) {
114
115 0 ▶ when /january/i { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/january/i)) 0 1 1
116 0 ▶ when /february/i { return 1; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/february/i)) 0 1 1
117 0 ▶ when /march/i { return 2; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/march/i)) 0 1 1
118 0 ▶ when /april/i { return 3; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/april/i)) 0 1 1
119 0 ▶ when /may/i { return 4; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/may/i)) 0 1 1
120 0 ▶ when /june/i { return 5; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/june/i)) 0 1 1
121 0 ▶ when /july/i { return 6; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/july/i)) 1 0 1
122 0 ▶ when /august/i { return 7; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/august/i)) 0 0 0
123 0 ▶ when /september/i { return 8; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/september/i)) 0 0 0
124 0 ▶ when /october/i { return 9; } # Note: Reserved keyword oct.
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/october/i)) 0 0 0
125 0 ▶ when /november/i { return 10; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/november/i)) 0 0 0
126 0 ▶ when /december/i { return 11; }
Branch: 1 branch
BranchTrueFalseTotal
if (&Switch::case(qr/december/i)) 0 0 0
127
128 0 };
129
130 0 carp("Did not match a valid month.\n");
131
132 } # END SUBROUTINE: B_to_strftime_m
133
134 # stftimeformat uses 0-11 for the month.
135 0 ▶sub m_to_strftime_m {
Subroutine m_to_strftime_m: not called CC=1 SCAR=6.9
Pod undocumented
136
137 # my $m = shift;
138 0 my $m = shift;
139 0 $m = $m - 1;
140 0 return $m;
141
142 # $m--;
143 # my $function = sub {
144 # my $matches = shift;
145 # return $matches->FETCH('m') - 1;
146 # };
147
148 # return $function;
149 }
150
151 1 1;
152
153 __END__;
↑ Summary Transform.pm »