line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Transform::Functions;
|
2
|
|
|
|
|
|
|
## SHOULD THIS BE ITS OWN PACKAGE SPACE
|
3
|
|
|
|
|
|
|
## NO. These are not methods but functions.
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
22
|
use 5.006;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
74
|
|
9
|
1
|
|
|
1
|
|
12
|
use Switch 'Perl6';
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
10
|
1
|
|
|
1
|
|
50331
|
use Tie::IxHash;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter;
|
13
|
1
|
|
|
1
|
|
5
|
use AutoLoader qw(AUTOLOAD);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
14
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub iI_p_to_strftime_H {
|
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
0
|
2
|
my $i = shift;
|
59
|
1
|
|
|
|
|
2
|
my $p = shift;
|
60
|
|
|
|
|
|
|
|
61
|
1
|
50
|
|
|
|
5
|
$i = 0 if ( $i == 12 );
|
62
|
1
|
50
|
|
|
|
7
|
$i += 12 if ( $p =~ /pm/i );
|
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
5
|
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
|
|
|
|
|
|
|
sub Y_to_strftime_y {
|
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
0
|
0
|
0
|
my $Y = shift;
|
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
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
|
|
|
|
|
|
|
sub bh_to_strftime_m {
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
0
|
0
|
my $bh = shift;
|
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
given($bh) {
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
0
|
when /jan/i { return 0; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
88
|
0
|
0
|
|
|
|
0
|
when /feb/i { return 1; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|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95
|
0
|
0
|
|
|
|
0
|
when /sep/i { return 8; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
96
|
0
|
0
|
|
|
|
0
|
when /Oct/i { return 9; } # Note: Reserved keyword oct.
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
97
|
0
|
0
|
|
|
|
0
|
when /nov/i { return 10; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
98
|
0
|
0
|
|
|
|
0
|
when /dec/i { return 11; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
};
|
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
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
|
|
|
|
|
|
|
sub B_to_strftime_m {
|
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
1
|
0
|
3
|
my $B = shift;
|
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
2
|
given($B) {
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
1
|
50
|
|
|
|
21
|
when /january/i { return 0; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
116
|
1
|
50
|
|
|
|
30
|
when /february/i { return 1; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
117
|
1
|
50
|
|
|
|
25
|
when /march/i { return 2; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
118
|
1
|
50
|
|
|
|
22
|
when /april/i { return 3; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
119
|
1
|
50
|
|
|
|
22
|
when /may/i { return 4; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
120
|
1
|
50
|
|
|
|
22
|
when /june/i { return 5; }
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
121
|
1
|
50
|
|
|
|
26
|
when /july/i { return 6; }
|
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
11
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
when /august/i { return 7; }
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
when /september/i { return 8; }
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
when /october/i { return 9; } # Note: Reserved keyword oct.
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
when /november/i { return 10; }
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
when /december/i { return 11; }
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
};
|
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
|
|
|
|
|
|
|
sub m_to_strftime_m {
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# my $m = shift;
|
138
|
0
|
|
|
0
|
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;
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
__END__; |