| 1 | ################################################### | ||||||||||||||||||||||||||||||||
| 2 | ## Interval.pm (Time::Interval) | ||||||||||||||||||||||||||||||||
| 3 | ## Andrew N. Hicox <andrew@hicox.com> | ||||||||||||||||||||||||||||||||
| 4 | ## http://www.hicox.com | ||||||||||||||||||||||||||||||||
| 5 | ## | ||||||||||||||||||||||||||||||||
| 6 | ## a module for dealing with time intervals | ||||||||||||||||||||||||||||||||
| 7 | ################################################### | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | ## Global Stuff ################################### | ||||||||||||||||||||||||||||||||
| 11 | package Time::Interval; | ||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 1 | require Exporter; | |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | #class global vars ... | ||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use vars qw($VERSION @EXPORT @ISA %intervals); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||
| 18 | 1 | @EXPORT = qw(&parseInterval &convertInterval &getInterval &coalesce); | |||||||||||||||||||||||||||||||
| 19 | 1 | $VERSION = 1.234; | |||||||||||||||||||||||||||||||
| 20 | #what everything is worth in seconds | ||||||||||||||||||||||||||||||||
| 21 | 1 | %intervals = ( | |||||||||||||||||||||||||||||||
| 22 | 'days' => ((60**2) * 24), | ||||||||||||||||||||||||||||||||
| 23 | 'hours' => (60 **2), | ||||||||||||||||||||||||||||||||
| 24 | 'minutes' => 60, | ||||||||||||||||||||||||||||||||
| 25 | 'seconds' => 1 | ||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | ## getInterval #################################### | ||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub getInterval { | ||||||||||||||||||||||||||||||
|
Subroutine
getInterval: called CC=8 SCAR=26.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 31 | 1 | my $date1 = shift(); | |||||||||||||||||||||||||||||||
| 32 | 1 | my $date2 = shift(); | |||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | my $string = shift() || ""; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | if ( (! $date1) || (! $date2) ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$date1 and $date2
MC/DC0%0/2
$date1 and $date2
$date1
$date2
Truth table33%1/3
A and B
A= $date1B= $date2
| |||||||||||||||||||||||||||||||||
| 35 | 0 | warn ("two dates are required for the getInterval method"); | |||||||||||||||||||||||||||||||
| 36 | 0 | return (undef); | |||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | 1 | require Date::Parse; | |||||||||||||||||||||||||||||||
| 39 | 1 | foreach ($date1, $date2){ | |||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | $_ = Date::Parse::str2time($_) || do { | ||||||||||||||||||||||||||||||
|
Condition33%1/3
Date::Parse::str2time($_) || do {
warn "failed to parse date: $!\n";
return undef
}
MC/DC0%0/2
Date::Parse::str2time($_) || do {
warn "failed to parse date: $!\n";
return undef
}
Date::Parse::str2time($_)
do {
warn "failed to parse date: $!\n";
return undef
}
Truth table33%1/3
A || B
A= Date::Parse::str2time($_)B= do {
warn "failed to parse date: $!\n";
return undef
}
| |||||||||||||||||||||||||||||||||
| 41 | 0 | warn ("failed to parse date: $!\n"); | |||||||||||||||||||||||||||||||
| 42 | 0 | return (undef); | |||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 1 | my %args = ( seconds => abs($date1 - $date2) ); | |||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if ($string =~/^small/i){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 48 | 0 | $args{'Small'} = 1; | |||||||||||||||||||||||||||||||
| 49 | }elsif($string !~/^\s*$/){ | ||||||||||||||||||||||||||||||||
| 50 | 0 | $args{'String'} = 1; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | 1 | my $data = parseInterval(%args); | |||||||||||||||||||||||||||||||
| 53 | 1 | return ($data); | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | ## convertInterval ################################ | ||||||||||||||||||||||||||||||||
| 58 | #'days' => $num, | ||||||||||||||||||||||||||||||||
| 59 | #'hours' => $num, | ||||||||||||||||||||||||||||||||
| 60 | #'minutes' => $num, | ||||||||||||||||||||||||||||||||
| 61 | #'seconds' => $num, | ||||||||||||||||||||||||||||||||
| 62 | #'ConvertTo' => 'days'|'hours'|'minutes'|'seconds' | ||||||||||||||||||||||||||||||||
| 63 | 14 | ▶ | sub convertInterval { | ||||||||||||||||||||||||||||||
|
Subroutine
convertInterval: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 64 | 14 | my %p = @_; | |||||||||||||||||||||||||||||||
| 65 | #ConvertTo, default is seconds | ||||||||||||||||||||||||||||||||
| 66 | 14 | ▶ | exists($p{'ConvertTo'}) || do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | 10 | $p{'ConvertTo'} = "seconds"; | |||||||||||||||||||||||||||||||
| 68 | 10 | ▶ | warn ("convertInterval: using default ConvertTo (seconds)") if $p{'Debug'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||||||
| 70 | #convert everything to seconds | ||||||||||||||||||||||||||||||||
| 71 | 14 | my $seconds = 0; | |||||||||||||||||||||||||||||||
| 72 | 14 | foreach ("days","hours","minutes","seconds"){ | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | #new 1.233 hotness: quantize seconds. | ||||||||||||||||||||||||||||||||
| 75 | 56 | ▶ | if ($_ eq "seconds"){ $p{$_} = int($p{$_}); } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | #as it were | ||||||||||||||||||||||||||||||||
| 78 | 56 | ▶ | if (exists($p{$_})){ $seconds += ($intervals{$_} * $p{$_}); } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | #send it back out into the desired output | ||||||||||||||||||||||||||||||||
| 81 | 14 | return (($seconds/$intervals{$p{'ConvertTo'}})); | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | ## parseInterval ################################## | ||||||||||||||||||||||||||||||||
| 86 | #'days' => $num, | ||||||||||||||||||||||||||||||||
| 87 | #'hours' => $num, | ||||||||||||||||||||||||||||||||
| 88 | #'minutes' => $num, | ||||||||||||||||||||||||||||||||
| 89 | #'seconds' => $num, | ||||||||||||||||||||||||||||||||
| 90 | 10 | ▶ | sub parseInterval { | ||||||||||||||||||||||||||||||
|
Subroutine
parseInterval: called CC=15 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 91 | 10 | my %p = @_; | |||||||||||||||||||||||||||||||
| 92 | #convert everything to seconds | ||||||||||||||||||||||||||||||||
| 93 | 10 | my $seconds = convertInterval(%p); | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | #new 1.233 hotness: quantize seconds. | ||||||||||||||||||||||||||||||||
| 96 | 10 | $seconds = int($seconds); | |||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | #do the thang | ||||||||||||||||||||||||||||||||
| 99 | 10 | my %time = ( | |||||||||||||||||||||||||||||||
| 100 | 'days' => 0, | ||||||||||||||||||||||||||||||||
| 101 | 'hours' => 0, | ||||||||||||||||||||||||||||||||
| 102 | 'minutes' => 0, | ||||||||||||||||||||||||||||||||
| 103 | 'seconds' => 0 | ||||||||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||||||
| 105 | 10 | ▶ | while ($seconds > 0){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | 26213 | foreach ("days","hours","minutes","seconds"){ | |||||||||||||||||||||||||||||||
| 107 | 27020 | ▶ | if ($seconds >= $intervals{$_}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 108 | 26213 | $time{$_} ++; | |||||||||||||||||||||||||||||||
| 109 | 26213 | $seconds -= $intervals{$_}; | |||||||||||||||||||||||||||||||
| 110 | 26213 | last; | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||
| 114 | #return data | ||||||||||||||||||||||||||||||||
| 115 | 10 | ▶ | if ($p{'Small'} && $p{'Small'} != 0) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$p{"Small"} and $p{"Small"} != 0
MC/DC50%1/2
$p{"Small"} and $p{"Small"} != 0
$p{"Small"}
$p{"Small"} != 0
Truth table66%2/3
A and B
A= $p{"Small"}B= $p{"Small"} != 0
| |||||||||||||||||||||||||||||||||
| 116 | #return a string? | ||||||||||||||||||||||||||||||||
| 117 | 5 | my @temp = (); | |||||||||||||||||||||||||||||||
| 118 | 5 | foreach ("days","hours","minutes","seconds"){ | |||||||||||||||||||||||||||||||
| 119 | 20 | ▶ | if ($time{$_} > 0){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | 10 | push (@temp, "$time{$_}".substr($_,0,1)); | |||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | 5 | ▶ | return join (" ", @temp) || "0s"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
join(' ', @temp) || '0s'
MC/DC0%0/1
join(' ', @temp) || '0s'
join(' ', @temp)
Truth table50%1/2
A
A= join(' ', @temp)
| |||||||||||||||||||||||||||||||||
| 124 | ▶ | }elsif ($p{'String'} && $p{'String'} != 0){ | |||||||||||||||||||||||||||||||
|
Condition66%2/3
$p{"String"} and $p{"String"} != 0
MC/DC50%1/2
$p{"String"} and $p{"String"} != 0
$p{"String"}
$p{"String"} != 0
Truth table66%2/3
A and B
A= $p{"String"}B= $p{"String"} != 0
| |||||||||||||||||||||||||||||||||
| 125 | #return a string? | ||||||||||||||||||||||||||||||||
| 126 | 4 | my @temp = (); | |||||||||||||||||||||||||||||||
| 127 | 4 | foreach ("days","hours","minutes","seconds"){ | |||||||||||||||||||||||||||||||
| 128 | 16 | ▶ | if ($time{$_} > 0){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 129 | 9 | ▶ | if ($time{$_} == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 0 | push (@temp, "$time{$_} ".substr($_,0,-1)); | |||||||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||||||
| 132 | 9 | push (@temp, "$time{$_} $_"); | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | 4 | ▶ | return (join (", ", @temp)) || "0 seconds"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
join(', ', @temp) || '0 seconds'
MC/DC0%0/1
join(', ', @temp) || '0 seconds'
join(', ', @temp)
Truth table50%1/2
A
A= join(', ', @temp)
| |||||||||||||||||||||||||||||||||
| 137 | }else{ | ||||||||||||||||||||||||||||||||
| 138 | #return a data structure | ||||||||||||||||||||||||||||||||
| 139 | 1 | return (\%time); | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | ## coalesce ####################################### | ||||||||||||||||||||||||||||||||
| 145 | #coalesce([ [$start1, $end1], [$start2, $end2] ... ]) | ||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | sub coalesce { | ||||||||||||||||||||||||||||||
|
Subroutine
coalesce: called CC=22 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 147 | 1 | require Date::Parse; | |||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | my $intervals = shift() || []; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 149 | 1 | my %epoch_map = (); | |||||||||||||||||||||||||||||||
| 150 | 1 | my ($flag, $repeat) = (0,1); | |||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | #convert each start / end to an epoch pair and stash 'em in epoch_map | ||||||||||||||||||||||||||||||||
| 153 | 1 | foreach my $int (@{$intervals}) { | |||||||||||||||||||||||||||||||
| 154 | 6 | foreach (@{$int}){ | |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | ## only convert if it's not already epoch time | ||||||||||||||||||||||||||||||||
| 157 | 12 | my $epoch = ""; | |||||||||||||||||||||||||||||||
| 158 | 12 | ▶ | if ($_ =~/^(\d{10})$/){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 159 | 0 | $epoch = $1; | |||||||||||||||||||||||||||||||
| 160 | }else{ | ||||||||||||||||||||||||||||||||
| 161 | 12 | $epoch = Date::Parse::str2time($_); | |||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | 12 | $epoch_map{$epoch} = $_; | |||||||||||||||||||||||||||||||
| 164 | 12 | $_ = $epoch; | |||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | #sort 'em by start time | ||||||||||||||||||||||||||||||||
| 169 | 1 | @{$intervals} = sort { $a->[0] <=> $b->[0] } @{$intervals}; | |||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | #flatten 'em | ||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | while ($repeat == 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | 4 | @{$intervals} = sort { | |||||||||||||||||||||||||||||||
| 174 | #if it's not an array ref, it's been destructo'd | ||||||||||||||||||||||||||||||||
| 175 | 10 | ▶ | if ( (ref($a) eq "ARRAY") && (ref($b) eq "ARRAY") ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $a eq "ARRAY" and ref $b eq "ARRAY"
MC/DC50%1/2
ref $a eq "ARRAY" and ref $b eq "ARRAY"
ref $a eq "ARRAY"
ref $b eq "ARRAY"
Truth table66%2/3
A and B
A= ref $a eq "ARRAY"B= ref $b eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | #if b is inside a | ||||||||||||||||||||||||||||||||
| 178 | 5 | ▶ | if (($b->[0] >= $a->[0]) && ($b->[0] <= $a->[1])){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$Time::Interval::b->[0] >= $Time::Interval::a->[0] and $Time::Interval::b->[0] <= $Time::Interval::a->[1]
MC/DC0%0/2
$Time::Interval::b->[0] >= $Time::Interval::a->[0] and $Time::Interval::b->[0] <= $Time::Interval::a->[1]
$Time::Interval::b->[0] >= $Time::Interval::a->[0]
$Time::Interval::b->[0] <= $Time::Interval::a->[1]
Truth table33%1/3
A and B
A= $Time::Interval::b->[0] >= $Time::Interval::a->[0]B= $Time::Interval::b->[0] <= $Time::Interval::a->[1]
| |||||||||||||||||||||||||||||||||
| 179 | #if b's end time is greater than a's, update a's end time | ||||||||||||||||||||||||||||||||
| 180 | 5 | ▶ | if ($b->[1] > $a->[1]){ $a->[1] = $b->[1]; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 181 | #destructo b | ||||||||||||||||||||||||||||||||
| 182 | 5 | $b = (); | |||||||||||||||||||||||||||||||
| 183 | 5 | $flag = 1; | |||||||||||||||||||||||||||||||
| 184 | 5 | return (1); | |||||||||||||||||||||||||||||||
| 185 | #if a is inside b | ||||||||||||||||||||||||||||||||
| 186 | ▶ | }elsif (($a->[0] >= $b->[0]) && ($a->[0] <= $b->[1])){ | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$Time::Interval::a->[0] >= $Time::Interval::b->[0] and $Time::Interval::a->[0] <= $Time::Interval::b->[1]
MC/DC0%0/2
$Time::Interval::a->[0] >= $Time::Interval::b->[0] and $Time::Interval::a->[0] <= $Time::Interval::b->[1]
$Time::Interval::a->[0] >= $Time::Interval::b->[0]
$Time::Interval::a->[0] <= $Time::Interval::b->[1]
Truth table0%0/3
A and B
A= $Time::Interval::a->[0] >= $Time::Interval::b->[0]B= $Time::Interval::a->[0] <= $Time::Interval::b->[1]
| |||||||||||||||||||||||||||||||||
| 187 | #if a's end time is greater than b's, update b's end time | ||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($a->[1] > $b->[1]){ $b->[1] = $a->[1]; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 189 | #destructo a | ||||||||||||||||||||||||||||||||
| 190 | 0 | $a = (); | |||||||||||||||||||||||||||||||
| 191 | 0 | $flag = 1; | |||||||||||||||||||||||||||||||
| 192 | 0 | return (0); | |||||||||||||||||||||||||||||||
| 193 | }else{ | ||||||||||||||||||||||||||||||||
| 194 | 0 | return (0); | |||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | }else{ | ||||||||||||||||||||||||||||||||
| 198 | 5 | return (1); | |||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | 4 | } @{$intervals}; | |||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | #weed out null elements | ||||||||||||||||||||||||||||||||
| 204 | 4 | my $i = 0; | |||||||||||||||||||||||||||||||
| 205 | 4 | foreach (@{$intervals}){ | |||||||||||||||||||||||||||||||
| 206 | 7 | ▶ | if ( ref($_) ne "ARRAY" ){ splice (@{$intervals}, $i, 1); } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 207 | 7 | $i ++; | |||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | #decide wether or not to repeat | ||||||||||||||||||||||||||||||||
| 211 | 4 | ▶ | if ($flag == 1){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 3 | $repeat = 1; | |||||||||||||||||||||||||||||||
| 213 | 3 | $flag = 0; | |||||||||||||||||||||||||||||||
| 214 | }else{ | ||||||||||||||||||||||||||||||||
| 215 | 1 | $repeat = 0; | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | #replace the epoch's with their time string equivalents | ||||||||||||||||||||||||||||||||
| 220 | 1 | foreach my $pair (@{$intervals}){ | |||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | if ( ref($pair) eq "ARRAY"){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 222 | 1 | foreach (@{$pair}){ $_ = $epoch_map{$_}; } | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | #weed out any remaining bum elements | ||||||||||||||||||||||||||||||||
| 227 | 1 | my $i = 0; | |||||||||||||||||||||||||||||||
| 228 | 1 | foreach (@{$intervals}){ | |||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | unless (ref($_) eq "ARRAY"){ splice (@{$intervals}, $i, 1); } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 230 | 1 | $i ++; | |||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||
| 232 | 1 | return ($intervals); | |||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||