Quartz.pm

filter: Statementstmt 79.0% 525 / 664 Branchbran 68.6% 258 / 376 Conditioncond 59.0% 156 / 264 MC/DCmcdc 34.9% 52 / 149 Subroutinesub 81.2% 26 / 32 Podpod 13.0% 3 / 23 totaltotal 67.6% 1020 / 1508 CC 279 SCAR 50.6
CC
279
Cov
72%
store_expression_vals
414.7
add_to_set
184.6
check_next
93.0
CRAP 158.4
↑ Summary Quartz/TreeSet.pm »
1 package DateTime::Event::Cron::Quartz;
2  
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  
6 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 $VERSION = '0.05';
9  
10 1 ▶use base qw/Class::Accessor/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Exception::Class (
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 'UnknownException',
17 'ParseException' => { fields => ['line'] },
18 'IllegalArgumentException' => {},
19 'UnsupportedOperationException' => {}
20 1 );
21  
22 1 ▶use DateTime::Event::Cron::Quartz::TreeSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use DateTime::Event::Cron::Quartz::ValueSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 Readonly my $MONDAY => 0;
26 1 Readonly my $TUESDAY => 1;
27 1 Readonly my $WEDNESDAY => 2;
28 1 Readonly my $THURSDAY => 3;
29 1 Readonly my $FRIDAY => 4;
30 1 Readonly my $SATURDAY => 5;
31 1 Readonly my $SUNDAY => 6;
32  
33 1 Readonly::Scalar my $SECOND => 0;
34 1 Readonly::Scalar my $MINUTE => 1;
35 1 Readonly::Scalar my $HOUR => 2;
36 1 Readonly::Scalar my $DAY_OF_MONTH => 3;
37 1 Readonly::Scalar my $MONTH => 4;
38 1 Readonly::Scalar my $DAY_OF_WEEK => 5;
39 1 Readonly::Scalar my $YEAR => 6;
40 1 Readonly::Scalar my $ALL_SPEC_INT => 99;
41 1 Readonly::Scalar my $NO_SPEC_INT => 98;
42 1 Readonly::Scalar my $ALL_SPEC => $ALL_SPEC_INT;
43 1 Readonly::Scalar my $NO_SPEC => $NO_SPEC_INT;
44  
45 1 Readonly::Scalar my $MONTH_MAP => {
46 JAN => 1,
47 FEB => 2,
48 MAR => 3,
49 APR => 4,
50 MAY => 5,
51 JUN => 6,
52 JUL => 7,
53 AUG => 8,
54 SEP => 9,
55 OCT => 10,
56 NOV => 11,
57 DEC => 12
58 };
59  
60 1 Readonly::Scalar my $DAY_MAP => {
61 MON => 1,
62 TUE => 2,
63 WED => 3,
64 THU => 4,
65 FRI => 5,
66 SAT => 6,
67 SUN => 7
68 };
69  
70 1 __PACKAGE__->mk_accessors(
71 qw/
72 cron_expression
73 time_zone
74 seconds
75 minutes
76 hours
77 days_of_month
78 months
79 days_of_week
80 years
81  
82 lastday_of_week
83 nthday_of_week
84 lastday_of_month
85 nearest_weekday
86 expression_parsed
87 /
88 );
89  
90 50 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
91 50 my ( $class, $cron_expression ) = @_;
92  
93 50 ▶ if ( !defined $cron_expression ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cron_expression) 0 50 50
94 0 IllegalArgumentException->throw(
95 error => 'cron expression cannot be undef' );
96 }
97  
98 50 my $this = bless {}, $class;
99  
100 # initialize fields values
101 50 $this->lastday_of_week(0);
102 50 $this->nthday_of_week(0);
103 50 $this->lastday_of_month(0);
104 50 $this->nearest_weekday(0);
105 50 $this->expression_parsed(0);
106  
107 50 $this->cron_expression( uc $cron_expression );
108  
109 50 $this->build_expression( $this->cron_expression );
110  
111 38 return $this;
112 }
113  
114 0 ▶sub is_satisfied_by {
Subroutine is_satisfied_by: not called CC=2 SCAR=17.9
Pod undocumented
115 0 my ( $this, $date ) = @_;
116  
117 0 my $time_after = $this->get_time_after($date);
118  
119 0 ▶ return ( ( defined $time_after )
Condition0%0/3
defined $time_after && 'DateTime'->compare($time_after, $date) == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $time_after && 'DateTime'->compare($time_after, $date) == 0
defined $time_after 'DateTime'->compare($time_after, $date) == 0
Truth table0%0/3
A && B
A= defined $time_afterB= 'DateTime'->compare($time_after, $date) == 0
ABresult
0X0
100
111
120 && ( DateTime->compare( $time_after, $date ) == 0 ) );
121 }
122  
123 97 ▶sub get_next_valid_time_after {
Subroutine get_next_valid_time_after: called CC=1 SCAR=0.0
Pod documented
124 97 my ( $this, $date ) = @_;
125  
126 97 return $this->get_time_after($date);
127 }
128  
129 0 ▶sub get_next_invalid_time_after {
Subroutine get_next_invalid_time_after: not called CC=3 SCAR=24.8
Pod undocumented
130 0 my ( $this, $last_date ) = @_;
131  
132 0 my $difference = 1;
133  
134 0 my $new_date = undef;
135  
136 # keep getting the next included time until it's farther than one second
137 # apart. At that point, lastDate is the last valid fire time. We return
138 # the second immediately following it.
139 0 ▶ while ( $difference == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($difference == 1) 0 0 0
140 0 $new_date = $this->get_time_after($last_date);
141  
142 0 $difference = $new_date->subtract_datetime_absolute($last_date);
143  
144 0 ▶ if ( $difference == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($difference == 1) 0 0 0
145 0 $last_date = $new_date;
146 }
147 }
148  
149 0 return $last_date->clone()->add( second => 1 );
150 }
151  
152 12 ▶sub is_valid_expression {
Subroutine is_valid_expression: called CC=2 SCAR=7.2
Pod documented
153 12 my ( $this, $cron_expression ) = @_;
154  
155 12 my $res = eval { $this->new($cron_expression); };
156  
157 12 ▶ if ( my $e = Exception::Class->caught('ParseException') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = "Exception::Class"->caught("ParseException")) 12 0 12
158 12 return 0;
159 }
160  
161 0 return 1;
162 }
163  
164 #//////////////////////////////////////////////////////////////////////////
165 #
166 # Expression Parsing Functions
167 #
168 #//////////////////////////////////////////////////////////////////////////
169  
170 50 ▶sub build_expression {
Subroutine build_expression: called CC=27 SCAR=35.6
Pod undocumented
171 50 my ( $this, $expression ) = @_;
172  
173 50 my $expression_parsed = 1;
174  
175 50 my $ret = eval {
176  
177 50 ▶ if ( !defined $this->seconds ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->seconds) 50 0 50
178 50 $this->seconds( DateTime::Event::Cron::Quartz::TreeSet->new );
179 }
180 50 ▶ if ( !defined $this->minutes ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->minutes) 50 0 50
181 50 $this->minutes( DateTime::Event::Cron::Quartz::TreeSet->new );
182 }
183 50 ▶ if ( !defined $this->hours ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->hours) 50 0 50
184 50 $this->hours( DateTime::Event::Cron::Quartz::TreeSet->new );
185 }
186 50 ▶ if ( !defined $this->days_of_month ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->days_of_month) 50 0 50
187 50 $this->days_of_month( DateTime::Event::Cron::Quartz::TreeSet->new );
188 }
189 50 ▶ if ( !defined $this->months ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->months) 50 0 50
190 50 $this->months( DateTime::Event::Cron::Quartz::TreeSet->new );
191 }
192 50 ▶ if ( !defined $this->days_of_week ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->days_of_week) 50 0 50
193 50 $this->days_of_week( DateTime::Event::Cron::Quartz::TreeSet->new );
194 }
195 50 ▶ if ( !defined $this->years ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $this->years) 50 0 50
196 50 $this->years( DateTime::Event::Cron::Quartz::TreeSet->new );
197 }
198  
199 50 my $expr_on = $SECOND;
200  
201 50 my @exprs_tok = split /\s+/sxm, $expression;
202  
203 50 foreach my $expr (@exprs_tok) {
204  
205 # not interested in after expression text
206 264 ▶ last if $expr_on > $YEAR;
Branch: 1 branch
BranchTrueFalseTotal
if $expr_on > $YEAR 0 264 264
207  
208 # throw an exception if L is used with other days of the month
209 264 ▶ if ( $expr_on == $DAY_OF_MONTH
Branch: 1 branch
BranchTrueFalseTotal
if ($expr_on == $DAY_OF_MONTH and index($expr, "L") != -1 and length $expr > 1 and index($expr, ",") != -1) 0 264 264
Condition88%8/9
$expr_on == $DAY_OF_MONTH and index($expr, "L") != -1 and length $expr > 1 and index($expr, ",") != -1
!ll&&!rl&&r
26310
$expr_on == $DAY_OF_MONTH and index($expr, "L") != -1 and length $expr > 1
!ll&&!rl&&r
26211
$expr_on == $DAY_OF_MONTH and index($expr, "L") != -1
!ll&&!rl&&r
221412
MC/DC0%0/4
$expr_on == $DAY_OF_MONTH and index($expr, "L") != -1 and length $expr > 1 and index($expr, ",") != -1
$expr_on == $DAY_OF_MONTH index($expr, "L") != -1 length $expr > 1 index($expr, ",") != -1
Truth table80%4/5
A and B and C and D
A= $expr_on == $DAY_OF_MONTHB= index($expr, "L") != -1C= length $expr > 1D= index($expr, ",") != -1
ABCDresult
0XXX0
10XX0
110X0
11100
11111
210 && index( $expr, 'L' ) != -1
211 && length($expr) > 1
212 && index( $expr, q/,/ ) >= 0 )
213 {
214  
215 0 ParseException->throw(
216 error =>
217 q/Support for specifying 'L' and 'LW' with other days of the month is not implemented/,
218 line => -1
219 );
220 }
221  
222 # throw an exception if L is used with other days of the week
223 264 ▶ if ( $expr_on == $DAY_OF_WEEK
Branch: 1 branch
BranchTrueFalseTotal
if ($expr_on == $DAY_OF_WEEK and index($expr, "L") != -1 and length $expr > 1 and index($expr, ",") != -1) 0 264 264
Condition77%7/9
$expr_on == $DAY_OF_WEEK and index($expr, "L") != -1 and length $expr > 1 and index($expr, ",") != -1
!ll&&!rl&&r
26220
$expr_on == $DAY_OF_WEEK and index($expr, "L") != -1 and length $expr > 1
!ll&&!rl&&r
26202
$expr_on == $DAY_OF_WEEK and index($expr, "L") != -1
!ll&&!rl&&r
225372
MC/DC0%0/4
$expr_on == $DAY_OF_WEEK and index($expr, "L") != -1 and length $expr > 1 and index($expr, ",") != -1
$expr_on == $DAY_OF_WEEK index($expr, "L") != -1 length $expr > 1 index($expr, ",") != -1
Truth table60%3/5
A and B and C and D
A= $expr_on == $DAY_OF_WEEKB= index($expr, "L") != -1C= length $expr > 1D= index($expr, ",") != -1
ABCDresult
0XXX0
10XX0
110X0
11100
11111
224 && index( $expr, 'L' ) != -1
225 && length($expr) > 1
226 && index( $expr, q/,/ ) >= 0 )
227 {
228  
229 0 ParseException->throw(
230 error =>
231 q/Support for specifying 'L' with other days of the week is not implemented/,
232 line => -1
233 );
234 }
235  
236 264 my @v_tok = split /,/sxm, $expr;
237 264 foreach my $v (@v_tok) {
238 291 $this->store_expression_vals( 0, $v, $expr_on );
239 }
240  
241 254 $expr_on++;
242 }
243  
244 40 ▶ if ( $expr_on <= $DAY_OF_WEEK ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr_on <= $DAY_OF_WEEK) 2 38 40
245 2 ParseException->throw(
246 error => q/Unexpected end of expression/,
247 line => ( length $expression )
248 );
249 }
250  
251 38 ▶ if ( $expr_on <= $YEAR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr_on <= $YEAR) 37 1 38
252 37 $this->store_expression_vals( 0, q/*/, $YEAR );
253 }
254  
255 #TreeSet
256 38 my $dow = $this->get_set($DAY_OF_WEEK);
257  
258 #TreeSet
259 38 my $dom = $this->get_set($DAY_OF_MONTH);
260  
261 # Copying the logic from the UnsupportedOperationException below
262 38 my $day_of_m_spec = !$dom->contains($NO_SPEC);
263 38 my $day_of_w_spec = !$dow->contains($NO_SPEC);
264  
265 38 ▶ if ( $day_of_m_spec && !$day_of_w_spec ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($day_of_m_spec and not $day_of_w_spec) { } 21 17 38
elsif ($day_of_w_spec and not $day_of_m_spec) { } 17 0 17
Condition66%2/3
$day_of_m_spec and not $day_of_w_spec
!ll&&!rl&&r
17021
MC/DC50%1/2
$day_of_m_spec and not $day_of_w_spec
$day_of_m_spec not $day_of_w_spec
Truth table66%2/3
A and not(B)
A= $day_of_m_specB= not $day_of_w_spec
ABresult
0X0
100
111
266  
267 # skip
268 }
269 ▶ elsif ( $day_of_w_spec && !$day_of_m_spec ) {
Condition33%1/3
$day_of_w_spec and not $day_of_m_spec
!ll&&!rl&&r
0017
MC/DC0%0/2
$day_of_w_spec and not $day_of_m_spec
$day_of_w_spec not $day_of_m_spec
Truth table33%1/3
A and not(B)
A= $day_of_w_specB= not $day_of_m_spec
ABresult
0X0
100
111
270  
271 # skip
272 }
273 else {
274 0 ParseException->throw(
275 error => q/Support for specifying both a day-of-week /
276 . q/AND a day-of-month parameter is not implemented./,
277 line => 0
278 );
279 }
280 };
281  
282 50 ▶ if ( my $pe = Exception::Class->caught('ParseException') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $pe = 'Exception::Class'->caught('ParseException')) { } 12 38 50
elsif (my $e = 'Exception::Class'->caught) { } 0 38 38
283 12 $pe->rethrow;
284 }
285 elsif ( my $e = Exception::Class->caught() ) {
286 0 ParseException->throw(
287 error => q/Illegal cron expression format (/ . $e->error . q/)/,
288 line => 0
289 );
290 }
291  
292 38 return;
293 }
294  
295 328 ▶sub store_expression_vals {
Subroutine store_expression_vals: called CC=65 SCAR=60.3
Pod undocumented
296 328 my ( $this, $pos, $s, $type ) = @_;
297  
298 328 my $incr = 0;
299 328 my $i = $this->skip_white_space( $pos, $s );
300 328 ▶ if ( $i >= ( length $s ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 0 328 328
301 0 return $i;
302 }
303  
304 328 my $c = ( substr $s, $i, 1 );
305 328 ▶ if ( ( ( ord $c ) >= ( ord 'A' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ord $c >= 65 and ord $c <= 90 and not $s eq "L" and not $s eq "LW") 7 321 328
Condition88%8/9
ord $c >= 65 and ord $c <= 90 and not $s eq "L" and not $s eq "LW"
!ll&&!rl&&r
32017
ord $c >= 65 and ord $c <= 90 and not $s eq "L"
!ll&&!rl&&r
31918
ord $c >= 65 and ord $c <= 90
!ll&&!rl&&r
31909
MC/DC75%3/4
ord $c >= 65 and ord $c <= 90 and not $s eq "L" and not $s eq "LW"
ord $c >= 65 ord $c <= 90 not $s eq "L" not $s eq "LW"
Truth table80%4/5
A and B and not(C) and not(D)
A= ord $c >= 65B= ord $c <= 90C= not $s eq "L"D= not $s eq "LW"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
306 && ( ( ord $c ) <= ( ord 'Z' ) )
307 && ( !( $s eq 'L' ) )
308 && ( !( $s eq 'LW' ) ) )
309 {
310 7 my $sub = ( substr $s, $i, $i + 3 );
311 7 my $sval = -1;
312 7 my $eval = -1;
313 7 ▶ if ( $type == $MONTH ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == $MONTH) { } 2 5 7
elsif ($type == $DAY_OF_WEEK) { } 3 2 5
314 2 $sval = $this->get_month_number($sub);
315 2 ▶ if ( $sval <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sval <= 0) 0 2 2
316 0 ParseException->throw(
317 error => q/Invalid Month value: '/ . $sub . q/'/,
318 line => $i
319 );
320 }
321 2 ▶ if ( ( length $s ) > $i + 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $s > $i + 3) 0 2 2
322 0 $c = ( substr $s, $i + 3, 1 );
323 0 ▶ if ( $c eq q/-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "-") 0 0 0
324 0 $i += ( 3 + 1 );
325 0 $sub = ( substr $s, $i, $i + 3 );
326 0 $eval = $this->get_month_number($sub);
327 0 ▶ if ( $eval <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eval <= 0) 0 0 0
328 0 ParseException->throw(
329 error => q/Invalid Month value: '/ . $sub . q/'/,
330 line => $i
331 );
332 }
333 }
334 }
335 }
336 elsif ( $type == $DAY_OF_WEEK ) {
337 3 $sval = $this->get_day_of_week_number($sub);
338 3 ▶ if ( $sval < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sval < 0) 0 3 3
339 0 ParseException->throw(
340 error => q/Invalid Day-of-Week value: '/ . $sub . q/'/,
341 line => $i
342 );
343 }
344 3 ▶ if ( length $s > $i + 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $s > $i + 3) 0 3 3
345 0 $c = substr $s, $i + 3, 1;
346 0 ▶ if ( $c eq q/-/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($c eq '-') { } 0 0 0
elsif ($c eq '#') { } 0 0 0
elsif ($c == 'L') { } 0 0 0
347 0 $i += ( 3 + 1 );
348 0 $sub = ( substr $s, $i, $i + 3 );
349 0 $eval = $this->get_day_of_week_number($sub);
350 0 ▶ if ( $eval < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eval < 0) 0 0 0
351 0 ParseException->throw(
352 error => q/Invalid Day-of-Week value: '/
353 . $sub . q/'/,
354 line => $i
355 );
356 }
357 }
358 elsif ( $c eq q/#/ ) {
359 0 my $ret = eval {
360 0 $i += ( 3 + 1 );
361 0 $this->nthday_of_week( int substr $s, $i );
362 0 ▶ if ( $this->nthday_of_week < 1
Branch: 1 branch
BranchTrueFalseTotal
if ($this->nthday_of_week < 1 or $this->nthday_of_week > 5) 0 0 0
Condition0%0/3
$this->nthday_of_week < 1 or $this->nthday_of_week > 5
l!l&&r!l&&!r
000
MC/DC0%0/2
$this->nthday_of_week < 1 or $this->nthday_of_week > 5
$this->nthday_of_week < 1 $this->nthday_of_week > 5
Truth table0%0/3
A or B
A= $this->nthday_of_week < 1B= $this->nthday_of_week > 5
ABresult
1X1
011
000
363 || $this->nthday_of_week > 5 )
364 {
365 0 Exception::Class->throw();
366 }
367 };
368  
369 0 ▶ if ( my $e = Exception::Class->caught() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = "Exception::Class"->caught) 0 0 0
370 0 ParseException->throw(
371 error =>
372 q/A numeric value between 1 and 5 must follow the '#' option/,
373 line => $i
374 );
375 }
376 }
377 elsif ( $c == 'L' ) {
378 0 $this->lastday_of_week(1);
379 0 $i++;
380 }
381 }
382  
383 }
384 else {
385 2 ParseException->throw(
386 error => q/Illegal characters for this position: '/
387 . $sub . q/'/,
388 line => $i
389 );
390 }
391 5 ▶ if ( $eval != -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eval != -1) 0 5 5
392 0 $incr = 1;
393 }
394 5 $this->add_to_set( $sval, $eval, $incr, $type );
395 5 return ( $i + 3 );
396 }
397  
398 321 ▶ if ( $c eq '?' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "?") 39 282 321
399 39 $i++;
400 39 ▶ if ( ( $i + 1 ) < length($s)
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < length $s and (substr($s, $i, 1) ne " " and substr($s, $i + 1, 1) ne "\t")) 0 39 39
Condition16%1/6
$i + 1 < length $s and (substr($s, $i, 1) ne " " and substr($s, $i + 1, 1) ne "\t")
!ll&&!rl&&r
3900
substr($s, $i, 1) ne " " and substr($s, $i + 1, 1) ne "\t"
!ll&&!rl&&r
000
MC/DC0%0/3
$i + 1 < length $s and (substr($s, $i, 1) ne " " and substr($s, $i + 1, 1) ne "\t")
$i + 1 < length $s substr($s, $i, 1) ne " " substr($s, $i + 1, 1) ne "\t"
Truth table25%1/4
A and B and C
A= $i + 1 < length $sB= substr($s, $i, 1) ne " "C= substr($s, $i + 1, 1) ne "\t"
ABCresult
0XX0
10X0
1100
1111
401 && ( substr( $s, $i, 1 ) ne ' ' && substr( $s, $i + 1, 1 ) ne "\t" )
402 )
403 {
404 0 ParseException->throw(
405 error => q/Illegal character after '?': / . substr( $s, $i, 1 ),
406 line => $i
407 );
408 }
409 39 ▶ if ( $type != $DAY_OF_WEEK && $type != $DAY_OF_MONTH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type != $DAY_OF_WEEK and $type != $DAY_OF_MONTH) 0 39 39
Condition66%2/3
$type != $DAY_OF_WEEK and $type != $DAY_OF_MONTH
!ll&&!rl&&r
21180
MC/DC0%0/2
$type != $DAY_OF_WEEK and $type != $DAY_OF_MONTH
$type != $DAY_OF_WEEK $type != $DAY_OF_MONTH
Truth table66%2/3
A and B
A= $type != $DAY_OF_WEEKB= $type != $DAY_OF_MONTH
ABresult
0X0
100
111
410 0 ParseException->throw(
411 error =>
412 q/'?' can only be specfied for Day-of-Month or Day-of-Week./,
413 line => $i
414 );
415 }
416 39 ▶ if ( $type == $DAY_OF_WEEK && !$this->lastday_of_month ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $DAY_OF_WEEK and not $this->lastday_of_month) 19 20 39
Condition100%3/3
$type == $DAY_OF_WEEK and not $this->lastday_of_month
!ll&&!rl&&r
18219
MC/DC100%2/2
$type == $DAY_OF_WEEK and not $this->lastday_of_month
$type == $DAY_OF_WEEK not $this->lastday_of_month
Truth table100%3/3
A and not(B)
A= $type == $DAY_OF_WEEKB= not $this->lastday_of_month
ABresult
0X0
100
111
417 19 my $val = int( $this->days_of_month->last_item() );
418 19 ▶ if ( $val == $NO_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val == $NO_SPEC_INT) 0 19 19
419 0 ParseException->throw(
420 error =>
421 q/'?' can only be specfied for Day-of-Month -OR- Day-of-Week./,
422 line => $i
423 );
424 }
425 }
426  
427 39 $this->add_to_set( $NO_SPEC_INT, -1, 0, $type );
428 39 return $i;
429 }
430  
431 282 ▶ if ( $c eq '*' || $c eq '/' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($c eq '*' or $c eq '/') { } 111 171 282
elsif ($c eq 'L') { } 2 169 171
elsif (ord $c >= 48 and ord $c <= 57) { } 168 1 169
Condition66%2/3
$c eq "*" or $c eq "/"
l!l&&r!l&&!r
1110171
MC/DC50%1/2
$c eq "*" or $c eq "/"
$c eq "*" $c eq "/"
Truth table66%2/3
A or B
A= $c eq "*"B= $c eq "/"
ABresult
1X1
011
000
432 111 ▶ if ( $c eq '*' && ( $i + 1 ) >= length($s) ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($c eq '*' and $i + 1 >= length $s) { } 110 1 111
elsif ($c eq '/' and $i + 1 >= length $s || substr($s, $i + 1, 1) eq ' ' || substr($s, $i + 1, 1) eq '\\t') { } 0 1 1
elsif ($c eq '*') { } 1 0 1
Condition66%2/3
$c eq "*" and $i + 1 >= length $s
!ll&&!rl&&r
01110
MC/DC50%1/2
$c eq "*" and $i + 1 >= length $s
$c eq "*" $i + 1 >= length $s
Truth table66%2/3
A and B
A= $c eq "*"B= $i + 1 >= length $s
ABresult
0X0
100
111
433 110 $this->add_to_set( $ALL_SPEC_INT, -1, $incr, $type );
434 110 return $i + 1;
435 }
436 ▶ elsif (
Condition11%1/9
$c eq "/" and $i + 1 >= length $s || substr($s, $i + 1, 1) eq " " || substr($s, $i + 1, 1) eq "\\t"
!ll&&!rl&&r
100
$i + 1 >= length $s or substr($s, $i + 1, 1) eq " " or substr($s, $i + 1, 1) eq "\\t"
l!l&&r!l&&!r
000
$i + 1 >= length $s or substr($s, $i + 1, 1) eq " "
l!l&&r!l&&!r
000
MC/DC0%0/4
$c eq "/" and $i + 1 >= length $s || substr($s, $i + 1, 1) eq " " || substr($s, $i + 1, 1) eq "\\t"
$c eq "/" $i + 1 >= length $s substr($s, $i + 1, 1) eq " " substr($s, $i + 1, 1) eq "\\t"
Truth table20%1/5
A and B or C or D
A= $c eq "/"B= $i + 1 >= length $sC= substr($s, $i + 1, 1) eq " "D= substr($s, $i + 1, 1) eq "\\t"
ABCDresult
0XXX0
10000
11XX1
101X1
10011
437 $c eq '/'
438 && ( ( $i + 1 ) >= length($s)
439 || substr( $s, $i + 1, 1 ) eq ' '
440 || substr( $s, $i + 1, 1 ) eq '\t' )
441 )
442 {
443 0 ParseException->throw(
444 error => q/'\/' must be followed by an integer./,
445 line => $i
446 );
447 }
448 elsif ( $c eq '*' ) {
449 1 $i++;
450 }
451 1 $c = substr( $s, $i, 1 );
452 1 ▶ if ( $c eq '/' ) { # is an increment specified?
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq '/') { } 1 0 1
453 1 $i++;
454 1 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 0 1 1
455 0 ParseException->throw(
456 error => q/Unexpected end of string./,
457 line => $i
458 );
459 }
460  
461 1 $incr = $this->get_numeric_value( $s, $i );
462  
463 1 $i++;
464 1 ▶ if ( $incr > 10 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incr > 10) 1 0 1
465 1 $i++;
466 }
467 1 ▶ if ( $incr > 59 && ( $type == $SECOND || $type == $MINUTE ) ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($incr > 59 and $type == $SECOND || $type == $MINUTE) { } 0 1 1
elsif ($incr > 23 and $type == $HOUR) { } 0 1 1
elsif ($incr > 31 and $type == $DAY_OF_MONTH) { } 0 1 1
elsif ($incr > 7 and $type == $DAY_OF_WEEK) { } 0 1 1
elsif ($incr > 12 and $type == $MONTH) { } 0 1 1
Condition16%1/6
$incr > 59 and $type == $SECOND || $type == $MINUTE
!ll&&!rl&&r
100
$type == $SECOND or $type == $MINUTE
l!l&&r!l&&!r
000
MC/DC0%0/3
$incr > 59 and $type == $SECOND || $type == $MINUTE
$incr > 59 $type == $SECOND $type == $MINUTE
Truth table25%1/4
A and B or C
A= $incr > 59B= $type == $SECONDC= $type == $MINUTE
ABCresult
0XX0
1000
11X1
1011
468 0 ParseException->throw(
469 error => 'Increment > 60 : ' . $incr,
470 line => $i
471 );
472 }
473 ▶ elsif ( $incr > 23 && ( $type == $HOUR ) ) {
Condition33%1/3
$incr > 23 and $type == $HOUR
!ll&&!rl&&r
010
MC/DC0%0/2
$incr > 23 and $type == $HOUR
$incr > 23 $type == $HOUR
Truth table33%1/3
A and B
A= $incr > 23B= $type == $HOUR
ABresult
0X0
100
111
474 0 ParseException->throw(
475 error => 'Increment > 24 : ' . $incr,
476 line => $i
477 );
478 }
479 ▶ elsif ( $incr > 31 && ( $type == $DAY_OF_MONTH ) ) {
Condition33%1/3
$incr > 31 and $type == $DAY_OF_MONTH
!ll&&!rl&&r
100
MC/DC0%0/2
$incr > 31 and $type == $DAY_OF_MONTH
$incr > 31 $type == $DAY_OF_MONTH
Truth table33%1/3
A and B
A= $incr > 31B= $type == $DAY_OF_MONTH
ABresult
0X0
100
111
480 0 ParseException->throw(
481 error => 'Increment > 31 : ' . $incr,
482 line => $i
483 );
484 }
485 ▶ elsif ( $incr > 7 && ( $type == $DAY_OF_WEEK ) ) {
Condition33%1/3
$incr > 7 and $type == $DAY_OF_WEEK
!ll&&!rl&&r
010
MC/DC0%0/2
$incr > 7 and $type == $DAY_OF_WEEK
$incr > 7 $type == $DAY_OF_WEEK
Truth table33%1/3
A and B
A= $incr > 7B= $type == $DAY_OF_WEEK
ABresult
0X0
100
111
486 0 ParseException->throw(
487 error => 'Increment > 7 : ' . $incr,
488 line => $i
489 );
490 }
491 ▶ elsif ( $incr > 12 && ( $type == $MONTH ) ) {
Condition33%1/3
$incr > 12 and $type == $MONTH
!ll&&!rl&&r
010
MC/DC0%0/2
$incr > 12 and $type == $MONTH
$incr > 12 $type == $MONTH
Truth table33%1/3
A and B
A= $incr > 12B= $type == $MONTH
ABresult
0X0
100
111
492 0 ParseException->throw(
493 error => 'Increment > 12 : ' . $incr,
494 line => $i
495 );
496 }
497 }
498 else {
499 0 $incr = 1;
500 }
501  
502 1 $this->add_to_set( $ALL_SPEC_INT, -1, $incr, $type );
503 1 return $i;
504 }
505 elsif ( $c eq 'L' ) {
506 2 $i++;
507 2 ▶ if ( $type == $DAY_OF_MONTH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $DAY_OF_MONTH) 2 0 2
508 2 $this->lastday_of_month(1);
509 }
510 2 ▶ if ( $type == $DAY_OF_WEEK ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $DAY_OF_WEEK) 0 2 2
511 0 $this->add_to_set( 7, 7, 0, $type );
512 }
513 2 ▶ if ( $type == $DAY_OF_MONTH && length($s) > $i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $DAY_OF_MONTH and length $s > $i) 1 1 2
Condition66%2/3
$type == $DAY_OF_MONTH and length $s > $i
!ll&&!rl&&r
011
MC/DC50%1/2
$type == $DAY_OF_MONTH and length $s > $i
$type == $DAY_OF_MONTH length $s > $i
Truth table66%2/3
A and B
A= $type == $DAY_OF_MONTHB= length $s > $i
ABresult
0X0
100
111
514 1 $c = substr( $s, $i, 1 );
515 1 ▶ if ( $c eq 'W' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "W") 1 0 1
516 1 $this->nearest_weekday(1);
517 1 $i++;
518 }
519 }
520 2 return $i;
521 }
522 ▶ elsif ( ord($c) >= ord('0') && ord($c) <= ord('9') ) {
Condition66%2/3
ord $c >= 48 and ord $c <= 57
!ll&&!rl&&r
10168
MC/DC50%1/2
ord $c >= 48 and ord $c <= 57
ord $c >= 48 ord $c <= 57
Truth table66%2/3
A and B
A= ord $c >= 48B= ord $c <= 57
ABresult
0X0
100
111
523 168 my $val = int($c);
524 168 $i++;
525 168 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) { } 99 69 168
526 99 $this->add_to_set( $val, -1, -1, $type );
527 }
528 else {
529 69 $c = substr( $s, $i, 1 );
530 69 ▶ if ( ord($c) >= ord('0') && ord($c) <= ord('9') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ord $c >= 48 and ord $c <= 57) 64 5 69
Condition100%3/3
ord $c >= 48 and ord $c <= 57
!ll&&!rl&&r
3264
MC/DC100%2/2
ord $c >= 48 and ord $c <= 57
ord $c >= 48 ord $c <= 57
Truth table100%3/3
A and B
A= ord $c >= 48B= ord $c <= 57
ABresult
0X0
100
111
531  
532 # ValueSet ??
533 64 my $vs = $this->get_value( $val, $s, $i );
534 64 $val = $vs->value;
535 64 $i = $vs->pos;
536 }
537 69 $i = $this->check_next( $i, $s, $val, $type );
538 64 return $i;
539 }
540 }
541 else {
542 1 ParseException->throw(
543 error => "Unexpected character: " . $c,
544 line => $i
545 );
546 }
547  
548 97 return $i;
549 }
550  
551 69 ▶sub check_next {
Subroutine check_next: called CC=24 SCAR=45.3
Pod undocumented
552 69 my $this = shift;
553  
554 69 my ( $pos, $s, $val, $type ) = @_;
555  
556 69 my $end = -1;
557 69 my $i = $pos;
558  
559 69 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 62 7 69
560 62 $this->add_to_set( $val, $end, -1, $type );
561 57 return $i;
562 }
563  
564 7 my $c = substr( $s, $pos, 1 );
565  
566 7 ▶ if ( $c eq 'L' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "L") 2 5 7
567 2 ▶ if ( $type == $DAY_OF_WEEK ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $DAY_OF_WEEK) { } 2 0 2
568 2 $this->lastday_of_week(1);
569 }
570 else {
571 0 ParseException->throw(
572 "'L' option is not valid here. (pos=" . $i . ")", $i );
573 }
574  
575 # TreeSet
576 2 my $set = $this->get_set($type);
577 2 $set->add( int($val) );
578 2 $i++;
579 2 return $i;
580 }
581  
582 5 ▶ if ( $c eq 'W' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "W") 1 4 5
583 1 ▶ if ( $type == $DAY_OF_MONTH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $DAY_OF_MONTH) { } 1 0 1
584 1 $this->nearest_weekday(1);
585 }
586 else {
587 0 ParseException->throw(
588 "'W' option is not valid here. (pos=" . $i . ")", $i );
589 }
590  
591 # TreeSet
592 1 my $set = $this->get_set($type);
593 1 $set->add( int($val) );
594 1 $i++;
595 1 return $i;
596 }
597  
598 4 ▶ if ( $c eq '#' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "#") 1 3 4
599 1 ▶ if ( $type != $DAY_OF_WEEK ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type != $DAY_OF_WEEK) 0 1 1
600 0 ParseException->throw(
601 error => "'#' option is not valid here. (pos=" . $i . ")",
602 line => $i
603 );
604 }
605 1 $i++;
606 1 eval {
607 1 $this->nthday_of_week( int( substr( $s, $i ) ) );
608 1 ▶ if ( $this->nthday_of_week < 1 || $this->nthday_of_week > 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->nthday_of_week < 1 or $this->nthday_of_week > 5) 0 1 1
Condition33%1/3
$this->nthday_of_week < 1 or $this->nthday_of_week > 5
l!l&&r!l&&!r
001
MC/DC0%0/2
$this->nthday_of_week < 1 or $this->nthday_of_week > 5
$this->nthday_of_week < 1 $this->nthday_of_week > 5
Truth table33%1/3
A or B
A= $this->nthday_of_week < 1B= $this->nthday_of_week > 5
ABresult
1X1
011
000
609 0 Exception::Class->throw();
610 }
611 };
612  
613 1 ▶ if ( my $e = Exception::Class->caught() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = "Exception::Class"->caught) 0 1 1
614 0 ParseException->throw(
615 error =>
616 "A numeric value between 1 and 5 must follow the '#' option",
617 line => $i
618 );
619 }
620  
621 # TreeSet
622 1 my $set = $this->get_set($type);
623 1 $set->add( int($val) );
624 1 $i++;
625 1 return $i;
626 }
627  
628 3 ▶ if ( $c eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "-") 3 0 3
629 3 $i++;
630 3 $c = substr( $s, $i, 1 );
631 3 my $v = int($c);
632 3 $end = $v;
633 3 $i++;
634 3 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 2 1 3
635 2 $this->add_to_set( $val, $end, 1, $type );
636 2 return $i;
637 }
638 1 $c = substr( $s, $i, 1 );
639 1 ▶ if ( $c >= '0' && $c <= '9' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c >= 0 and $c <= 9) 1 0 1
Condition33%1/3
$c >= 0 and $c <= 9
!ll&&!rl&&r
001
MC/DC0%0/2
$c >= 0 and $c <= 9
$c >= 0 $c <= 9
Truth table33%1/3
A and B
A= $c >= 0B= $c <= 9
ABresult
0X0
100
111
640  
641 # ValueSet
642 1 my $vs = $this->get_value( $v, $s, $i );
643 1 my $v1 = $vs->value;
644 1 $end = $v1;
645 1 $i = $vs->pos;
646 }
647 1 ▶ if ( $i < length($s) && ( ( $c = substr( $s, $i, 1 ) ) eq '/' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $s and ($c = substr($s, $i, 1)) eq '/') { } 0 1 1
Condition33%1/3
$i < length $s and ($c = substr($s, $i, 1)) eq "/"
!ll&&!rl&&r
100
MC/DC0%0/2
$i < length $s and ($c = substr($s, $i, 1)) eq "/"
$i < length $s ($c = substr($s, $i, 1)) eq "/"
Truth table33%1/3
A and B
A= $i < length $sB= ($c = substr($s, $i, 1)) eq "/"
ABresult
0X0
100
111
648 0 $i++;
649 0 $c = substr( $s, $i, 1 );
650 0 my $v2 = int($c);
651 0 $i++;
652 0 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 0 0 0
653 0 $this->add_to_set( $val, $end, $v2, $type );
654 0 return $i;
655 }
656 0 $c = substr( $s, $i, 1 );
657 0 ▶ if ( $c >= '0' && $c <= '9' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c >= '0' and $c <= '9') { } 0 0 0
Condition0%0/3
$c >= 0 and $c <= 9
!ll&&!rl&&r
000
MC/DC0%0/2
$c >= 0 and $c <= 9
$c >= 0 $c <= 9
Truth table0%0/3
A and B
A= $c >= 0B= $c <= 9
ABresult
0X0
100
111
658  
659 # ValueSet
660 0 my $vs = $this->get_value( $v2, $s, $i );
661 0 my $v3 = $vs->value;
662 0 $this->add_to_set( $val, $end, $v3, $type );
663 0 $i = $vs->pos;
664 0 return $i;
665 }
666 else {
667 0 $this->add_to_set( $val, $end, $v2, $type );
668 0 return $i;
669 }
670 }
671 else {
672 1 $this->add_to_set( $val, $end, 1, $type );
673 1 return $i;
674 }
675 }
676  
677 0 ▶ if ( $c eq '/' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "/") 0 0 0
678 0 $i++;
679 0 $c = substr( $s, $i, 1 );
680 0 my $v2 = int($c);
681 0 $i++;
682 0 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 0 0 0
683 0 $this->add_to_set( $val, $end, $v2, $type );
684 0 return $i;
685 }
686 0 $c = substr( $s, $i, 1 );
687 0 ▶ if ( $c >= '0' && $c <= '9' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c >= '0' and $c <= '9') { } 0 0 0
Condition0%0/3
$c >= 0 and $c <= 9
!ll&&!rl&&r
000
MC/DC0%0/2
$c >= 0 and $c <= 9
$c >= 0 $c <= 9
Truth table0%0/3
A and B
A= $c >= 0B= $c <= 9
ABresult
0X0
100
111
688  
689 # ValueSet
690 0 my $vs = $this->get_value( $v2, $s, $i );
691 0 my $v3 = $vs->value;
692 0 $this->add_to_set( $val, $end, $v3, $type );
693 0 $i = $vs->pos;
694 0 return $i;
695 }
696 else {
697 0 ParseException->throw(
698 error => "Unexpected character '" . $c . "' after '/'", line => $i );
699 }
700 }
701  
702 0 $this->add_to_set( $val, $end, 0, $type );
703 0 $i++;
704 0 return $i;
705 }
706  
707 0 ▶sub get_cron_expression {
Subroutine get_cron_expression: not called CC=1 SCAR=6.9
Pod undocumented
708 0 my $this = shift;
709  
710 0 return $this->cron_expression;
711 }
712  
713 328 ▶sub skip_white_space {
Subroutine skip_white_space: called CC=4 SCAR=16.4
Pod undocumented
714 328 my $this = shift;
715  
716 328 my ( $i, $s ) = @_;
717  
718 328 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $s and substr($s, $i, 1) eq " " || substr($s, $i, 1) eq "\\t") 0 328 328
Condition33%2/6
$i < length $s and substr($s, $i, 1) eq " " || substr($s, $i, 1) eq "\\t"
!ll&&!rl&&r
03280
substr($s, $i, 1) eq " " or substr($s, $i, 1) eq "\\t"
l!l&&r!l&&!r
00328
MC/DC0%0/3
$i < length $s and substr($s, $i, 1) eq " " || substr($s, $i, 1) eq "\\t"
$i < length $s substr($s, $i, 1) eq " " substr($s, $i, 1) eq "\\t"
Truth table25%1/4
A and B or C
A= $i < length $sB= substr($s, $i, 1) eq " "C= substr($s, $i, 1) eq "\\t"
ABCresult
0XX0
1000
11X1
1011
719 ;
720 $i < length($s)
721 && ( substr( $s, $i, 1 ) eq ' ' || substr( $s, $i, 1 ) eq '\t' ) ;
722 $i++
723 )
724 {
725 ;
726 }
727  
728 328 return $i;
729 }
730  
731 1 ▶sub find_next_white_space {
Subroutine find_next_white_space: called CC=4 SCAR=14.5
Pod undocumented
732 1 my $this = shift;
733  
734 1 my ( $i, $s ) = @_;
735  
736 1 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $s and substr($s, $i, 1) ne " " || substr($s, $i, 1) ne "\\t") 2 1 3
Condition50%3/6
$i < length $s and substr($s, $i, 1) ne " " || substr($s, $i, 1) ne "\\t"
!ll&&!rl&&r
102
substr($s, $i, 1) ne " " or substr($s, $i, 1) ne "\\t"
l!l&&r!l&&!r
200
MC/DC33%1/3
$i < length $s and substr($s, $i, 1) ne " " || substr($s, $i, 1) ne "\\t"
$i < length $s substr($s, $i, 1) ne " " substr($s, $i, 1) ne "\\t"
Truth table50%2/4
A and B or C
A= $i < length $sB= substr($s, $i, 1) ne " "C= substr($s, $i, 1) ne "\\t"
ABCresult
0XX0
1000
11X1
1011
737 ;
738 $i < length($s)
739 && ( substr( $s, $i, 1 ) ne ' ' || substr( $s, $i, 1 ) ne '\t' ) ;
740 $i++
741 )
742 {
743 ;
744 }
745  
746 1 return $i;
747 }
748  
749 319 ▶sub add_to_set {
Subroutine add_to_set: called CC=74 SCAR=52.2
Pod undocumented
750 319 my $this = shift;
751  
752 319 my ( $val, $end, $incr, $type ) = @_;
753  
754 #TreeSet
755 319 my $set = $this->get_set($type);
756  
757 319 ▶ if ( $type == $SECOND || $type == $MINUTE ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($type == $SECOND or $type == $MINUTE) { } 93 226 319
elsif ($type == $HOUR) { } 53 173 226
elsif ($type == $DAY_OF_MONTH) { } 44 129 173
elsif ($type == $MONTH) { } 51 78 129
elsif ($type == $DAY_OF_WEEK) { } 40 38 78
Condition100%3/3
$type == $SECOND or $type == $MINUTE
l!l&&r!l&&!r
4647226
MC/DC100%2/2
$type == $SECOND or $type == $MINUTE
$type == $SECOND $type == $MINUTE
Truth table100%3/3
A or B
A= $type == $SECONDB= $type == $MINUTE
ABresult
1X1
011
000
758 93 ▶ if ( ( $val < 0 || $val > 59 || $end > 59 )
Branch: 1 branch
BranchTrueFalseTotal
if ($val < 0 || $val > 59 || $end > 59 and $val != $ALL_SPEC_INT) 1 92 93
Condition77%7/9
$val < 0 || $val > 59 || $end > 59 and $val != $ALL_SPEC_INT
!ll&&!rl&&r
75171
$val < 0 or $val > 59 or $end > 59
l!l&&r!l&&!r
18075
$val < 0 or $val > 59
l!l&&r!l&&!r
01875
MC/DC50%2/4
$val < 0 || $val > 59 || $end > 59 and $val != $ALL_SPEC_INT
$val < 0 $val > 59 $end > 59 $val != $ALL_SPEC_INT
Truth table42%3/7
A or B or C and D
A= $val < 0B= $val > 59C= $end > 59D= $val != $ALL_SPEC_INT
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
759 && ( $val != $ALL_SPEC_INT ) )
760 {
761 1 ParseException->throw(
762 error => "Minute and Second values must be between 0 and 59",
763 line => -1
764 );
765 }
766 }
767 elsif ( $type == $HOUR ) {
768 53 ▶ if ( ( $val < 0 || $val > 23 || $end > 23 )
Branch: 1 branch
BranchTrueFalseTotal
if ($val < 0 || $val > 23 || $end > 23 and $val != $ALL_SPEC_INT) 1 52 53
Condition77%7/9
$val < 0 || $val > 23 || $end > 23 and $val != $ALL_SPEC_INT
!ll&&!rl&&r
42101
$val < 0 or $val > 23 or $end > 23
l!l&&r!l&&!r
11042
$val < 0 or $val > 23
l!l&&r!l&&!r
01142
MC/DC50%2/4
$val < 0 || $val > 23 || $end > 23 and $val != $ALL_SPEC_INT
$val < 0 $val > 23 $end > 23 $val != $ALL_SPEC_INT
Truth table42%3/7
A or B or C and D
A= $val < 0B= $val > 23C= $end > 23D= $val != $ALL_SPEC_INT
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
769 && ( $val != $ALL_SPEC_INT ) )
770 {
771 1 ParseException->throw(
772 error => "Hour values must be between 0 and 23",
773 line => -1
774 );
775 }
776 }
777 elsif ( $type == $DAY_OF_MONTH ) {
778 44 ▶ if ( ( $val < 1 || $val > 31 || $end > 31 )
Branch: 1 branch
BranchTrueFalseTotal
if ($val < 1 || $val > 31 || $end > 31 and $val != $ALL_SPEC_INT and $val != $NO_SPEC_INT) 2 42 44
Condition91%11/12
$val < 1 || $val > 31 || $end > 31 and $val != $ALL_SPEC_INT and $val != $NO_SPEC_INT
!ll&&!rl&&r
24182
$val < 1 || $val > 31 || $end > 31 and $val != $ALL_SPEC_INT
!ll&&!rl&&r
15920
$val < 1 or $val > 31 or $end > 31
l!l&&r!l&&!r
29015
$val < 1 or $val > 31
l!l&&r!l&&!r
12815
MC/DC80%4/5
$val < 1 || $val > 31 || $end > 31 and $val != $ALL_SPEC_INT and $val != $NO_SPEC_INT
$val < 1 $val > 31 $end > 31 $val != $ALL_SPEC_INT $val != $NO_SPEC_INT
Truth table50%5/10
A or B or C and D and E
A= $val < 1B= $val > 31C= $end > 31D= $val != $ALL_SPEC_INTE= $val != $NO_SPEC_INT
ABCDEresult
000XX0
1XX0X0
01X0X0
0010X0
1XX100
01X100
001100
1XX111
01X111
001111
779 && ( $val != $ALL_SPEC_INT )
780 && ( $val != $NO_SPEC_INT ) )
781 {
782 2 ParseException->throw(
783 error => "Day of month values must be between 1 and 31",
784 line => -1
785 );
786 }
787 }
788 elsif ( $type == $MONTH ) {
789 51 ▶ if ( ( $val < 1 || $val > 12 || $end > 12 )
Branch: 1 branch
BranchTrueFalseTotal
if ($val < 1 || $val > 12 || $end > 12 and $val != $ALL_SPEC_INT) 2 49 51
Condition88%8/9
$val < 1 || $val > 12 || $end > 12 and $val != $ALL_SPEC_INT
!ll&&!rl&&r
17322
$val < 1 or $val > 12 or $end > 12
l!l&&r!l&&!r
34017
$val < 1 or $val > 12
l!l&&r!l&&!r
13317
MC/DC75%3/4
$val < 1 || $val > 12 || $end > 12 and $val != $ALL_SPEC_INT
$val < 1 $val > 12 $end > 12 $val != $ALL_SPEC_INT
Truth table57%4/7
A or B or C and D
A= $val < 1B= $val > 12C= $end > 12D= $val != $ALL_SPEC_INT
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
790 && ( $val != $ALL_SPEC_INT ) )
791 {
792 2 ParseException->throw(
793 error => "Month values must be between 1 and 12",
794 line => -1
795 );
796 }
797 }
798 elsif ( $type == $DAY_OF_WEEK ) {
799 40 ▶ if ( ( $val == 0 || $val > 7 || $end > 7 )
Branch: 1 branch
BranchTrueFalseTotal
if ($val == 0 || $val > 7 || $end > 7 and $val != $ALL_SPEC_INT and $val != $NO_SPEC_INT) 1 39 40
Condition83%10/12
$val == 0 || $val > 7 || $end > 7 and $val != $ALL_SPEC_INT and $val != $NO_SPEC_INT
!ll&&!rl&&r
18211
$val == 0 || $val > 7 || $end > 7 and $val != $ALL_SPEC_INT
!ll&&!rl&&r
12622
$val == 0 or $val > 7 or $end > 7
l!l&&r!l&&!r
28012
$val == 0 or $val > 7
l!l&&r!l&&!r
02812
MC/DC60%3/5
$val == 0 || $val > 7 || $end > 7 and $val != $ALL_SPEC_INT and $val != $NO_SPEC_INT
$val == 0 $val > 7 $end > 7 $val != $ALL_SPEC_INT $val != $NO_SPEC_INT
Truth table40%4/10
A or B or C and D and E
A= $val == 0B= $val > 7C= $end > 7D= $val != $ALL_SPEC_INTE= $val != $NO_SPEC_INT
ABCDEresult
000XX0
1XX0X0
01X0X0
0010X0
1XX100
01X100
001100
1XX111
01X111
001111
800 && ( $val != $ALL_SPEC_INT )
801 && ( $val != $NO_SPEC_INT ) )
802 {
803 1 ParseException->throw(
804 error => "Day-of-Week values must be between 1 and 7",
805 line => -1
806 );
807 }
808 }
809  
810 312 ▶ if ( ( $incr == 0 || $incr == -1 ) && $val != $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incr == 0 || $incr == -1 and $val != $ALL_SPEC_INT) 198 114 312
Condition100%6/6
$incr == 0 || $incr == -1 and $val != $ALL_SPEC_INT
!ll&&!rl&&r
4110198
$incr == 0 or $incr == -1
l!l&&r!l&&!r
1541544
MC/DC100%3/3
$incr == 0 || $incr == -1 and $val != $ALL_SPEC_INT
$incr == 0 $incr == -1 $val != $ALL_SPEC_INT
Truth table80%4/5
A or B and C
A= $incr == 0B= $incr == -1C= $val != $ALL_SPEC_INT
ABCresult
00X0
1X00
0100
1X11
0111
811 {
812 198 ▶ if ( $val != -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val != -1) { } 198 0 198
813 198 $set->add($val);
814 }
815 else {
816 0 $set->add($NO_SPEC);
817 }
818 }
819  
820 198 return;
821 }
822  
823 114 my $start_at = $val;
824 114 my $stop_at = $end;
825  
826 114 ▶ if ( $val == $ALL_SPEC_INT && $incr <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val == $ALL_SPEC_INT and $incr <= 0) 110 4 114
Condition100%3/3
$val == $ALL_SPEC_INT and $incr <= 0
!ll&&!rl&&r
31110
MC/DC100%2/2
$val == $ALL_SPEC_INT and $incr <= 0
$val == $ALL_SPEC_INT $incr <= 0
Truth table100%3/3
A and B
A= $val == $ALL_SPEC_INTB= $incr <= 0
ABresult
0X0
100
111
827 110 $incr = 1;
828 110 $set->add($ALL_SPEC); # put in a marker, but also fill values
829 }
830  
831 114 ▶ if ( $type == $SECOND || $type == $MINUTE ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($type == $SECOND or $type == $MINUTE) { } 18 96 114
elsif ($type == $HOUR) { } 10 86 96
elsif ($type == $DAY_OF_MONTH) { } 9 77 86
elsif ($type == $MONTH) { } 32 45 77
elsif ($type == $DAY_OF_WEEK) { } 7 38 45
elsif ($type == $YEAR) { } 38 0 38
Condition100%3/3
$type == $SECOND or $type == $MINUTE
l!l&&r!l&&!r
61296
MC/DC100%2/2
$type == $SECOND or $type == $MINUTE
$type == $SECOND $type == $MINUTE
Truth table100%3/3
A or B
A= $type == $SECONDB= $type == $MINUTE
ABresult
1X1
011
000
832 18 ▶ if ( $stop_at == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at == -1) 17 1 18
833 17 $stop_at = 59;
834 }
835 18 ▶ if ( $start_at == -1 || $start_at == $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_at == -1 or $start_at == $ALL_SPEC_INT) 17 1 18
Condition66%2/3
$start_at == -1 or $start_at == $ALL_SPEC_INT
l!l&&r!l&&!r
0171
MC/DC50%1/2
$start_at == -1 or $start_at == $ALL_SPEC_INT
$start_at == -1 $start_at == $ALL_SPEC_INT
Truth table66%2/3
A or B
A= $start_at == -1B= $start_at == $ALL_SPEC_INT
ABresult
1X1
011
000
836 17 $start_at = 0;
837 }
838 }
839 elsif ( $type == $HOUR ) {
840 10 ▶ if ( $stop_at == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at == -1) 10 0 10
841 10 $stop_at = 23;
842 }
843 10 ▶ if ( $start_at == -1 || $start_at == $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_at == -1 or $start_at == $ALL_SPEC_INT) 10 0 10
Condition33%1/3
$start_at == -1 or $start_at == $ALL_SPEC_INT
l!l&&r!l&&!r
0100
MC/DC0%0/2
$start_at == -1 or $start_at == $ALL_SPEC_INT
$start_at == -1 $start_at == $ALL_SPEC_INT
Truth table33%1/3
A or B
A= $start_at == -1B= $start_at == $ALL_SPEC_INT
ABresult
1X1
011
000
844 10 $start_at = 0;
845 }
846 }
847 elsif ( $type == $DAY_OF_MONTH ) {
848 9 ▶ if ( $stop_at == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at == -1) 9 0 9
849 9 $stop_at = 31;
850 }
851 9 ▶ if ( $start_at == -1 || $start_at == $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_at == -1 or $start_at == $ALL_SPEC_INT) 9 0 9
Condition33%1/3
$start_at == -1 or $start_at == $ALL_SPEC_INT
l!l&&r!l&&!r
090
MC/DC0%0/2
$start_at == -1 or $start_at == $ALL_SPEC_INT
$start_at == -1 $start_at == $ALL_SPEC_INT
Truth table33%1/3
A or B
A= $start_at == -1B= $start_at == $ALL_SPEC_INT
ABresult
1X1
011
000
852 9 $start_at = 1;
853 }
854 }
855 elsif ( $type == $MONTH ) {
856 32 ▶ if ( $stop_at == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at == -1) 32 0 32
857 32 $stop_at = 12;
858 }
859 32 ▶ if ( $start_at == -1 || $start_at == $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_at == -1 or $start_at == $ALL_SPEC_INT) 32 0 32
Condition33%1/3
$start_at == -1 or $start_at == $ALL_SPEC_INT
l!l&&r!l&&!r
0320
MC/DC0%0/2
$start_at == -1 or $start_at == $ALL_SPEC_INT
$start_at == -1 $start_at == $ALL_SPEC_INT
Truth table33%1/3
A or B
A= $start_at == -1B= $start_at == $ALL_SPEC_INT
ABresult
1X1
011
000
860 32 $start_at = 1;
861 }
862 }
863 elsif ( $type == $DAY_OF_WEEK ) {
864 7 ▶ if ( $stop_at == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at == -1) 6 1 7
865 6 $stop_at = 7;
866 }
867 7 ▶ if ( $start_at == -1 || $start_at == $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_at == -1 or $start_at == $ALL_SPEC_INT) 6 1 7
Condition66%2/3
$start_at == -1 or $start_at == $ALL_SPEC_INT
l!l&&r!l&&!r
061
MC/DC50%1/2
$start_at == -1 or $start_at == $ALL_SPEC_INT
$start_at == -1 $start_at == $ALL_SPEC_INT
Truth table66%2/3
A or B
A= $start_at == -1B= $start_at == $ALL_SPEC_INT
ABresult
1X1
011
000
868 6 $start_at = 1;
869 }
870 }
871 elsif ( $type == $YEAR ) {
872 38 ▶ if ( $stop_at == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at == -1) 37 1 38
873 37 $stop_at = 2099;
874 }
875 38 ▶ if ( $start_at == -1 || $start_at == $ALL_SPEC_INT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_at == -1 or $start_at == $ALL_SPEC_INT) 37 1 38
Condition66%2/3
$start_at == -1 or $start_at == $ALL_SPEC_INT
l!l&&r!l&&!r
0371
MC/DC50%1/2
$start_at == -1 or $start_at == $ALL_SPEC_INT
$start_at == -1 $start_at == $ALL_SPEC_INT
Truth table66%2/3
A or B
A= $start_at == -1B= $start_at == $ALL_SPEC_INT
ABresult
1X1
011
000
876 37 $start_at = 1970;
877 }
878 }
879  
880 # if the end of the range is before the start, then we need to overflow into
881 # the next day, month etc. This is done by adding the maximum amount for that
882 # type, and using modulus max to determine the value being added.
883 114 my $max = -1;
884 114 ▶ if ( $stop_at < $start_at ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_at < $start_at) 0 114 114
885 0 ▶ if ( $type == $SECOND ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($type == $SECOND) { } 0 0 0
elsif ($type == $MINUTE) { } 0 0 0
elsif ($type == $HOUR) { } 0 0 0
elsif ($type == $MONTH) { } 0 0 0
elsif ($type == $DAY_OF_WEEK) { } 0 0 0
elsif ($type == $DAY_OF_MONTH) { } 0 0 0
elsif ($type == $YEAR) { } 0 0 0
886 0 $max = 60;
887 }
888 elsif ( $type == $MINUTE ) {
889 0 $max = 60;
890 }
891 elsif ( $type == $HOUR ) {
892 0 $max = 24;
893 }
894 elsif ( $type == $MONTH ) {
895 0 $max = 12;
896 }
897 elsif ( $type == $DAY_OF_WEEK ) {
898 0 $max = 7;
899 }
900 elsif ( $type == $DAY_OF_MONTH ) {
901 0 $max = 31;
902 }
903 elsif ( $type == $YEAR ) {
904 0 IllegalArgumentException->throw(
905 error => "Start year must be less than stop year" );
906 }
907 else {
908 0 IllegalArgumentException->throw(
909 error => "Unexpected type encountered" );
910 }
911  
912 0 $stop_at += $max;
913 }
914  
915 114 ▶ for ( my $i = $start_at ; $i <= $stop_at ; $i += $incr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $stop_at) 6724 114 6838
916 6724 ▶ if ( $max == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max == -1) { } 6724 0 6724
917  
918 # ie: there's no max to overflow over
919 6724 $set->add( int($i) );
920 }
921 else {
922  
923 # take the modulus to get the real value
924 0 my $i2 = $i % $max;
925  
926 # 1-indexed ranges should not include 0, and should include their max
927 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($i2 == 0 and $type == $MONTH || $type == $DAY_OF_WEEK || $type == $DAY_OF_MONTH) 0 0 0
Condition0%0/9
$i2 == 0 and $type == $MONTH || $type == $DAY_OF_WEEK || $type == $DAY_OF_MONTH
!ll&&!rl&&r
000
$type == $MONTH or $type == $DAY_OF_WEEK or $type == $DAY_OF_MONTH
l!l&&r!l&&!r
000
$type == $MONTH or $type == $DAY_OF_WEEK
l!l&&r!l&&!r
000
MC/DC0%0/4
$i2 == 0 and $type == $MONTH || $type == $DAY_OF_WEEK || $type == $DAY_OF_MONTH
$i2 == 0 $type == $MONTH $type == $DAY_OF_WEEK $type == $DAY_OF_MONTH
Truth table0%0/5
A and B or C or D
A= $i2 == 0B= $type == $MONTHC= $type == $DAY_OF_WEEKD= $type == $DAY_OF_MONTH
ABCDresult
0XXX0
10000
11XX1
101X1
10011
928 $i2 == 0
929 && ( $type == $MONTH
930 || $type == $DAY_OF_WEEK
931 || $type == $DAY_OF_MONTH )
932 )
933 {
934 0 $i2 = $max;
935 }
936  
937 0 $set->add( int($i2) );
938 }
939 }
940 }
941  
942 399 ▶sub get_set {
Subroutine get_set: called CC=8 SCAR=20.8
Pod undocumented
943 399 my $this = shift;
944  
945 399 my $type = shift;
946  
947 399 ▶ if ( $type == $SECOND ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($type == $SECOND) { } 46 353 399
elsif ($type == $MINUTE) { } 47 306 353
elsif ($type == $HOUR) { } 53 253 306
elsif ($type == $MONTH) { } 51 202 253
elsif ($type == $DAY_OF_MONTH) { } 83 119 202
elsif ($type == $DAY_OF_WEEK) { } 81 38 119
elsif ($type == $YEAR) { } 38 0 38
948 46 return $this->seconds;
949 }
950 elsif ( $type == $MINUTE ) {
951 47 return $this->minutes;
952 }
953 elsif ( $type == $HOUR ) {
954 53 return $this->hours;
955 }
956 elsif ( $type == $MONTH ) {
957 51 return $this->months;
958 }
959 elsif ( $type == $DAY_OF_MONTH ) {
960 83 return $this->days_of_month;
961 }
962 elsif ( $type == $DAY_OF_WEEK ) {
963 81 return $this->days_of_week;
964 }
965 elsif ( $type == $YEAR ) {
966 38 return $this->years;
967 }
968 else {
969 0 return undef;
970 }
971 }
972  
973 65 ▶sub get_value {
Subroutine get_value: called CC=5 SCAR=16.1
Pod undocumented
974 65 my $this = shift;
975  
976 65 my ( $v, $s, $i ) = @_;
977  
978 65 my $c = substr( $s, $i, 1 );
979 65 my $s1 = "$v";
980  
981 65 ▶ while ( ord($c) >= ord('0') && ord($c) <= ord('9') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ord $c >= 48 and ord $c <= 57) 69 2 71
Condition100%3/3
ord $c >= 48 and ord $c <= 57
!ll&&!rl&&r
1169
MC/DC100%2/2
ord $c >= 48 and ord $c <= 57
ord $c >= 48 ord $c <= 57
Truth table100%3/3
A and B
A= ord $c >= 48B= ord $c <= 57
ABresult
0X0
100
111
982 69 $s1 .= $c;
983 69 $i++;
984 69 ▶ if ( $i >= length($s) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= length $s) 63 6 69
985 63 last;
986 }
987 6 $c = substr( $s, $i, 1 );
988 }
989  
990 # ValueSet
991 65 my $val = DateTime::Event::Cron::Quartz::ValueSet->new;
992  
993 65 ▶ $val->pos( ( $i < length($s) ) ? $i : $i + 1 );
Branch: 1 branch
BranchTrueFalseTotal
$i < length $s ? : 2 63 65
994 65 $val->value( int($s1) );
995 65 return $val;
996 }
997  
998 1 ▶sub get_numeric_value {
Subroutine get_numeric_value: called CC=2 SCAR=7.1
Pod undocumented
999 1 my $this = shift;
1000  
1001 1 my ( $s, $i ) = @_;
1002  
1003 1 my $end_of_val = $this->find_next_white_space( $i, $s );
1004 1 my $val = substr( $s, $i, $end_of_val );
1005  
1006 1 ▶ if ( !( $val =~ /^\d+$/ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($val =~ /^\d+$/) 0 1 1
1007 0 ParseException->throw(
1008 error => "value is not numeric: " . $val,
1009 line => $i
1010 );
1011 }
1012  
1013 1 return int($val);
1014 }
1015  
1016 2 ▶sub get_month_number {
Subroutine get_month_number: called CC=2 SCAR=7.2
Pod undocumented
1017 2 my $this = shift;
1018  
1019 2 my $s = shift;
1020  
1021 2 my $integer = $MONTH_MAP->{$s};
1022  
1023 2 ▶ if ( !defined $integer ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $integer) 0 2 2
1024 0 return -1;
1025 }
1026  
1027 2 return $integer;
1028 }
1029  
1030 3 ▶sub get_day_of_week_number {
Subroutine get_day_of_week_number: called CC=2 SCAR=7.2
Pod undocumented
1031 3 my $this = shift;
1032  
1033 3 my $s = shift;
1034  
1035 3 my $integer = $DAY_MAP->{$s};
1036  
1037 3 ▶ if ( !defined $integer ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $integer) 0 3 3
1038 0 return -1;
1039 }
1040  
1041 3 return $integer;
1042 }
1043  
1044 #//////////////////////////////////////////////////////////////////////////
1045 #
1046 # Computation Functions
1047 #
1048 #//////////////////////////////////////////////////////////////////////////
1049  
1050 97 ▶sub get_time_after {
Subroutine get_time_after: called CC=66 SCAR=43.4
Pod undocumented
1051 97 my $this = shift;
1052  
1053 97 my $after_time = shift->clone;
1054  
1055 # move ahead one second, since we're computing the time *after* the
1056 # given time
1057 97 $after_time->add( seconds => 1 );
1058  
1059 # operable calendar
1060 97 my $cl = $after_time->clone;
1061  
1062 97 my $got_one = 0;
1063  
1064 # loop until we've computed the next time, or we've past the endTime
1065 97 ▶ ITER: while ( !$got_one ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($got_one) 555 97 652
1066  
1067 #if (endTime != null && cl.getTime().after(endTime)) return null;
1068 555 ▶ if ( ( $cl->year ) > 2999 ) { # prevent endless loop...
Branch: 1 branch
BranchTrueFalseTotal
if ($cl->year > 2999) 0 555 555
1069 0 return undef;
1070 }
1071  
1072  
1073 # get second.................................................
1074 {
1075 # sorted set
1076 # SortedSet
1077 555 my $st = undef;
1078 555 my $t = 0;
1079
1080 555 my $sec = $cl->second;
1081 555 my $min = $cl->minute;
1082
1083 555 $st = $this->seconds->tail_set($sec);
1084
1085 555 ▶ if ( defined $st && $st->size() != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st and $st->size != 0) { } 466 89 555
Condition66%2/3
defined $st and $st->size != 0
!ll&&!rl&&r
890466
MC/DC50%1/2
defined $st and $st->size != 0
defined $st $st->size != 0
Truth table66%2/3
A and B
A= defined $stB= $st->size != 0
ABresult
0X0
100
111
1086 466 $sec = int( $st->first_item() );
1087 }
1088 else {
1089 89 $sec = int( $this->seconds->first_item() );
1090 89 $cl->add(minutes => 1);
1091 }
1092 555 $cl->set( second => $sec );
1093 }
1094  
1095 # get minute.................................................
1096 {
1097 555 my $min = $cl->minute;
1098 555 my $hr = $cl->hour;
1099 555 my $t = -1;
1100  
1101 555 my $st = $this->minutes->tail_set($min);
1102 555 ▶ if ( defined $st && $st->size() != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st and $st->size != 0) { } 487 68 555
Condition66%2/3
defined $st and $st->size != 0
!ll&&!rl&&r
680487
MC/DC50%1/2
defined $st and $st->size != 0
defined $st $st->size != 0
Truth table66%2/3
A and B
A= defined $stB= $st->size != 0
ABresult
0X0
100
111
1103 487 $t = $min;
1104 487 $min = int( $st->first_item );
1105 }
1106 else {
1107 # next hour
1108 68 $min = int( $this->minutes->first_item() );
1109 68 $hr++;
1110 }
1111  
1112 555 ▶ if ( $min != $t ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($min != $t) 209 346 555
1113 209 $cl->set( second => 0, minute => $min );
1114 209 $this->set_calendar_hour( $cl, $hr );
1115 209 next ITER;
1116 }
1117  
1118 346 $cl->set( minute => $min );
1119 }
1120  
1121 # get hour...................................................
1122 {
1123 555 my $hr = $cl->hour;
1124 346 my $day = $cl->day;
1125 346 my $t = -1;
1126
1127 346 my $st = $this->hours->tail_set( int($hr) );
1128 346 ▶ if ( defined $st && $st->size() != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st and $st->size != 0) { } 287 59 346
Condition66%2/3
defined $st and $st->size != 0
!ll&&!rl&&r
590287
MC/DC50%1/2
defined $st and $st->size != 0
defined $st $st->size != 0
Truth table66%2/3
A and B
A= defined $stB= $st->size != 0
ABresult
0X0
100
111
1129 287 $t = $hr;
1130 287 $hr = int( $st->first_item() );
1131 }
1132 else {
1133 59 $hr = int( $this->hours->first_item() );
1134 59 $day++;
1135 }
1136  
1137 346 ▶ if ( $hr != $t ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr != $t) 156 190 346
1138  
1139 156 $cl->add( days => $day - $cl->day );
1140 156 $cl->set( second => 0, minute => 0 );
1141
1142 156 $this->set_calendar_hour( $cl, $hr );
1143 156 next ITER;
1144 }
1145
1146 190 $cl->set( hour => $hr );
1147 }
1148  
1149 # get day...................................................
1150 {
1151 346 my $day = $cl->day;
1152 190 my $mon = $cl->month;
1153 190 my $t = -1;
1154 190 my $tmon = $mon;
1155  
1156 190 my $day_of_m_spec = !$this->days_of_month->contains($NO_SPEC);
1157 190 my $day_of_w_spec = !$this->days_of_week->contains($NO_SPEC);
1158  
1159 190 my $min = $cl->min;
1160 190 my $sec = $cl->sec;
1161 190 my $hr = $cl->hour;
1162  
1163 190 ▶ if ( $day_of_m_spec && !$day_of_w_spec )
Branch: 2 branches
BranchTrueFalseTotal
if ($day_of_m_spec and not $day_of_w_spec) { } 112 78 190
elsif ($day_of_w_spec and not $day_of_m_spec) { } 78 0 78
Condition66%2/3
$day_of_m_spec and not $day_of_w_spec
!ll&&!rl&&r
780112
MC/DC50%1/2
$day_of_m_spec and not $day_of_w_spec
$day_of_m_spec not $day_of_w_spec
Truth table66%2/3
A and not(B)
A= $day_of_m_specB= not $day_of_w_spec
ABresult
0X0
100
111
1164 {
1165 # get day by day of month rule
1166 112 my $st = $this->days_of_month->tail_set( int($day) );
1167 112 ▶ if ( $this->lastday_of_month ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($this->lastday_of_month) { } 10 102 112
elsif ($this->nearest_weekday) { } 5 97 102
elsif (defined $st and $st->size != 0) { } 84 13 97
1168 10 ▶ if ( !$this->nearest_weekday ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $this->nearest_weekday) { } 4 6 10
1169 4 $t = $day;
1170 4 $day = $this->getlastday_of_month( $mon, $cl->year );
1171 }
1172 else {
1173 6 $t = $day;
1174 6 $day = $this->getlastday_of_month( $mon, $cl->year );
1175
1176 6 my $tcal = DateTime->new(
1177 second => 0,
1178 minute => 0,
1179 hour => 0,
1180 day => $day,
1181 month => $mon,
1182 year => $cl->year
1183 );
1184
1185 6 my $ldom = $this->getlastday_of_month( $mon, $cl->year );
1186 6 my $dow = $tcal->day_of_week_0;
1187
1188 6 ▶ if ( $dow == $SATURDAY && $day == 1 ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($dow == $SATURDAY and $day == 1) { } 0 6 6
elsif ($dow == $SATURDAY) { } 2 4 6
elsif ($dow == $SUNDAY and $day == $ldom) { } 0 4 4
elsif ($dow == $SUNDAY) { } 0 4 4
Condition66%2/3
$dow == $SATURDAY and $day == 1
!ll&&!rl&&r
420
MC/DC0%0/2
$dow == $SATURDAY and $day == 1
$dow == $SATURDAY $day == 1
Truth table66%2/3
A and B
A= $dow == $SATURDAYB= $day == 1
ABresult
0X0
100
111
1189 0 $day += 2;
1190 }
1191 elsif ( $dow == $SATURDAY ) {
1192 2 $day -= 1;
1193 }
1194 ▶ elsif ( $dow == $SUNDAY && $day == $ldom ) {
Condition33%1/3
$dow == $SUNDAY and $day == $ldom
!ll&&!rl&&r
400
MC/DC0%0/2
$dow == $SUNDAY and $day == $ldom
$dow == $SUNDAY $day == $ldom
Truth table33%1/3
A and B
A= $dow == $SUNDAYB= $day == $ldom
ABresult
0X0
100
111
1195 0 $day -= 2;
1196 }
1197 elsif ( $dow == $SUNDAY ) {
1198 0 $day += 1;
1199 }
1200
1201 $tcal->set(
1202 6 second => $sec,
1203 minute => $min,
1204 hour => $hr,
1205 day => $day,
1206 month => $mon
1207 );
1208
1209 # tcal before afterTime
1210 6 ▶ if ( DateTime->compare( $tcal, $after_time ) < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("DateTime"->compare($tcal, $after_time) < 0) 0 6 6
1211 0 $day = 1;
1212 0 $mon++;
1213 }
1214 }
1215 }
1216 elsif ( $this->nearest_weekday ) {
1217 5 $t = $day;
1218 5 $day = int( $this->days_of_month->first_item() );
1219
1220 5 my $tcal = DateTime->new(
1221 second => 0,
1222 minute => 0,
1223 hour => 0,
1224 day => $day,
1225 month => $mon,
1226 year => $cl->year
1227 );
1228  
1229 5 my $ldom = $this->getlastday_of_month( $mon, $cl->year );
1230 5 my $dow = $tcal->day_of_week_0;
1231  
1232 5 ▶ if ( $dow == $SATURDAY && $day == 1 ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($dow == $SATURDAY and $day == 1) { } 0 5 5
elsif ($dow == $SATURDAY) { } 2 3 5
elsif ($dow == $SUNDAY and $day == $ldom) { } 0 3 3
elsif ($dow == $SUNDAY) { } 0 3 3
Condition66%2/3
$dow == $SATURDAY and $day == 1
!ll&&!rl&&r
320
MC/DC0%0/2
$dow == $SATURDAY and $day == 1
$dow == $SATURDAY $day == 1
Truth table66%2/3
A and B
A= $dow == $SATURDAYB= $day == 1
ABresult
0X0
100
111
1233 0 $day += 2;
1234 }
1235 elsif ( $dow == $SATURDAY ) {
1236 2 $day -= 1;
1237 }
1238 ▶ elsif ( $dow == $SUNDAY && $day == $ldom ) {
Condition33%1/3
$dow == $SUNDAY and $day == $ldom
!ll&&!rl&&r
300
MC/DC0%0/2
$dow == $SUNDAY and $day == $ldom
$dow == $SUNDAY $day == $ldom
Truth table33%1/3
A and B
A= $dow == $SUNDAYB= $day == $ldom
ABresult
0X0
100
111
1239 0 $day -= 2;
1240 }
1241 elsif ( $dow == $SUNDAY ) {
1242 0 $day += 1;
1243 }
1244  
1245 $tcal->set(
1246 5 second => $sec,
1247 minute => $min,
1248 hour => $hr,
1249 day => $day,
1250 month => $mon
1251 );
1252
1253 # tcal before afterTime
1254 5 ▶ if ( DateTime->compare( $tcal, $after_time ) < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("DateTime"->compare($tcal, $after_time) < 0) 2 3 5
1255 2 $day = int( $this->days_of_month->first_item() );
1256 2 $mon++;
1257 }
1258 }
1259 ▶ elsif ( defined $st && $st->size() != 0 ) {
Condition66%2/3
defined $st and $st->size != 0
!ll&&!rl&&r
13084
MC/DC50%1/2
defined $st and $st->size != 0
defined $st $st->size != 0
Truth table66%2/3
A and B
A= defined $stB= $st->size != 0
ABresult
0X0
100
111
1260 84 $t = $day;
1261 84 $day = int( $st->first_item );
1262  
1263 # make sure we don't over-run a short month, such as february
1264 84 my $last_day = $this->getlastday_of_month( $mon, $cl->year );
1265 84 ▶ if ( $day > $last_day ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day > $last_day) 11 73 84
1266 11 $day = int( $this->days_of_month->first_item() );
1267 11 $mon++;
1268 }
1269 }
1270 else {
1271 13 $day = int( $this->days_of_month->first_item() );
1272 13 $mon++;
1273 }
1274  
1275 112 ▶ if ( $day != $t || $mon != $tmon ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day != $t or $mon != $tmon) 43 69 112
Condition100%3/3
$day != $t or $mon != $tmon
l!l&&r!l&&!r
42169
MC/DC100%2/2
$day != $t or $mon != $tmon
$day != $t $mon != $tmon
Truth table100%3/3
A or B
A= $day != $tB= $mon != $tmon
ABresult
1X1
011
000
1276 43 $cl->set(
1277 second => 0,
1278 minute => 0,
1279 hour => 0
1280 );
1281  
1282 43 ▶ if ($mon > 12) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mon > 12) { } 1 42 43
1283 1 $cl->set(month => 12, day => 1);
1284 1 $cl->add(months => $mon - 12);
1285 } else {
1286 42 $cl->set(month => $mon, day => $day);
1287 }
1288  
1289 43 next ITER;
1290 }
1291 }
1292 ▶ elsif ( $day_of_w_spec && !$day_of_m_spec )
Condition33%1/3
$day_of_w_spec and not $day_of_m_spec
!ll&&!rl&&r
0078
MC/DC0%0/2
$day_of_w_spec and not $day_of_m_spec
$day_of_w_spec not $day_of_m_spec
Truth table33%1/3
A and not(B)
A= $day_of_w_specB= not $day_of_m_spec
ABresult
0X0
100
111
1293 {
1294 # get day by day of week rule
1295  
1296 78 ▶ if ( $this->lastday_of_week )
Branch: 2 branches
BranchTrueFalseTotal
if ($this->lastday_of_week) { } 16 62 78
elsif ($this->nthday_of_week != 0) { } 8 54 62
1297 { # are we looking for the last XXX day of
1298 # the month?
1299  
1300 16 my $dow = int( $this->days_of_week->first_item() ); # desired d-o-w
1301 16 my $c_dow = $cl->day_of_week(); # current d-o-w
1302 16 my $days_to_add = 0;
1303 16 ▶ if ( $c_dow < $dow ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c_dow < $dow) 4 12 16
1304 4 $days_to_add = $dow - $c_dow;
1305 }
1306 16 ▶ if ( $c_dow > $dow ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c_dow > $dow) 6 10 16
1307 6 $days_to_add = $dow + ( 7 - $c_dow );
1308 }
1309
1310 16 my $l_day = $this->getlastday_of_month( $mon, $cl->year );
1311
1312 16 ▶ if ( $day + $days_to_add > $l_day ) { # did we already miss the
Branch: 1 branch
BranchTrueFalseTotal
if ($day + $days_to_add > $l_day) 4 12 16
1313 # last one?
1314 4 $cl->set(
1315 second => 0,
1316 minute => 0,
1317 hour => 0,
1318 day => 1,
1319 month => $mon + 1
1320 );
1321 4 next ITER;
1322 }
1323
1324 # find date of last occurance of this day in this month...
1325 12 ▶ while ( ( $day + $days_to_add + 7 ) <= $l_day ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day + $days_to_add + 7 <= $l_day) 17 12 29
1326 17 $days_to_add += 7;
1327 }
1328
1329 12 $day += $days_to_add;
1330
1331 12 ▶ if ( $days_to_add > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($days_to_add > 0) 6 6 12
1332 6 $cl->set(
1333 second => 0,
1334 minute => 0,
1335 hour => 0,
1336 day => $day,
1337 month => $mon
1338 );
1339 6 next ITER;
1340 }
1341
1342 }
1343 elsif ( $this->nthday_of_week != 0 ) {
1344
1345 # are we looking for the Nth XXX day in the month?
1346 8 my $dow = int( $this->days_of_week->first_item() ); # desired
1347 # d-o-w
1348 8 my $c_dow = $cl->day_of_week(); # current d-o-w
1349 8 my $days_to_add = 0;
1350 8 ▶ if ( $c_dow < $dow ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c_dow < $dow) { } 1 7 8
elsif ($c_dow > $dow) { } 4 3 7
1351 1 $days_to_add = $dow - $c_dow;
1352 }
1353 elsif ( $c_dow > $dow ) {
1354 4 $days_to_add = $dow + ( 7 - $c_dow );
1355 }
1356
1357 8 my $day_shifted = 0;
1358 8 ▶ if ( $days_to_add > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($days_to_add > 0) 5 3 8
1359 5 $day_shifted = 1;
1360 }
1361
1362 8 $day += $days_to_add;
1363 8 my $week_of_month = int( $day / 7 );
1364 8 ▶ if ( $day % 7 > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day % 7 > 0) 8 0 8
1365 8 $week_of_month++;
1366 }
1367
1368 8 $days_to_add = ( $this->nthday_of_week - $week_of_month ) * 7;
1369 8 $day += $days_to_add;
1370 8 ▶ if ( $days_to_add < 0
Branch: 2 branches
BranchTrueFalseTotal
if ($days_to_add < 0 or $day > $this->getlastday_of_month($mon, $cl->year)) { } 2 6 8
elsif ($days_to_add > 0 or $day_shifted) { } 3 3 6
Condition66%2/3
$days_to_add < 0 or $day > $this->getlastday_of_month($mon, $cl->year)
l!l&&r!l&&!r
206
MC/DC50%1/2
$days_to_add < 0 or $day > $this->getlastday_of_month($mon, $cl->year)
$days_to_add < 0 $day > $this->getlastday_of_month($mon, $cl->year)
Truth table66%2/3
A or B
A= $days_to_add < 0B= $day > $this->getlastday_of_month($mon, $cl->year)
ABresult
1X1
011
000
1371 || $day > $this->getlastday_of_month( $mon, $cl->year ) )
1372 {
1373 2 $cl->set(
1374 second => 0,
1375 minute => 0,
1376 hour => 0,
1377 day => 1,
1378 month => $mon
1379 );
1380  
1381 2 $cl->add(months => 1);
1382 2 next ITER;
1383 }
1384 ▶ elsif ( $days_to_add > 0 || $day_shifted ) {
Condition66%2/3
$days_to_add > 0 or $day_shifted
l!l&&r!l&&!r
303
MC/DC50%1/2
$days_to_add > 0 or $day_shifted
$days_to_add > 0 $day_shifted
Truth table66%2/3
A or B
A= $days_to_add > 0B= $day_shifted
ABresult
1X1
011
000
1385 3 $cl->set(
1386 second => 0,
1387 minute => 0,
1388 hour => 0,
1389 day => $day,
1390 month => $mon
1391 );
1392 3 next ITER;
1393 }
1394 }
1395 else {
1396 54 my $c_dow = $cl->day_of_week; # current d-o-w
1397 54 my $dow = int( $this->days_of_week->first_item() ); # desired
1398 # d-o-w
1399 54 my $st = $this->days_of_week->tail_set( int($c_dow) );
1400 54 ▶ if ( defined $st && $st->size() > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st and $st->size > 0) 46 8 54
Condition66%2/3
defined $st and $st->size > 0
!ll&&!rl&&r
8046
MC/DC50%1/2
defined $st and $st->size > 0
defined $st $st->size > 0
Truth table66%2/3
A and B
A= defined $stB= $st->size > 0
ABresult
0X0
100
111
1401 46 $dow = int( $st->first_item() );
1402 }
1403
1404 54 my $days_to_add = 0;
1405 54 ▶ if ( $c_dow < $dow ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c_dow < $dow) 10 44 54
1406 10 $days_to_add = $dow - $c_dow;
1407 }
1408 54 ▶ if ( $c_dow > $dow ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c_dow > $dow) 8 46 54
1409 8 $days_to_add = $dow + ( 7 - $c_dow );
1410 }
1411
1412 54 my $l_day = $this->getlastday_of_month( $mon, $cl->year );
1413
1414 54 ▶ if ( $day + $days_to_add > $l_day ) { # will we pass the end of
Branch: 2 branches
BranchTrueFalseTotal
if ($day + $days_to_add > $l_day) { } 1 53 54
elsif ($days_to_add > 0) { } 17 36 53
1415 # the month?
1416 # switch to the next month
1417 1 $cl->set(
1418 second => 0,
1419 minute => 0,
1420 hour => 0,
1421 day => 1
1422 );
1423
1424 1 $cl->add(months => 1);
1425
1426 1 next ITER;
1427 }
1428 elsif ( $days_to_add > 0 ) { # are we swithing days?
1429 # just add some more days
1430 17 $cl->set(
1431 second => 0,
1432 minute => 0,
1433 hour => 0,
1434 month => $mon
1435 );
1436
1437 17 $cl->add(days => $days_to_add);
1438
1439 17 next ITER;
1440 }
1441 }
1442 }
1443 else { # dayOfWSpec && !dayOfMSpec
1444 0 UnsupportedOperationException->throw(
1445 error => q/Support for specifying both /
1446 . q/a day-of-week AND a day-of-month parameter is not implemented./
1447 );
1448
1449 # TODO:
1450 }
1451  
1452 114 $cl->set( day => $day );
1453 }
1454  
1455 # get month...................................................
1456 {
1457 190 my $mon = $cl->month;
1458 114 my $year = $cl->year;
1459 114 my $t = -1;
1460
1461 # test for expressions that never generate a valid fire date,
1462 # but keep looping...
1463 114 ▶ if ( $year > 2099 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 2099) 0 114 114
1464 0 return undef;
1465 }
1466
1467 114 my $st = $this->months->tail_set( int($mon) );
1468 114 ▶ if ( defined $st && $st->size() != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st and $st->size != 0) { } 102 12 114
Condition66%2/3
defined $st and $st->size != 0
!ll&&!rl&&r
120102
MC/DC50%1/2
defined $st and $st->size != 0
defined $st $st->size != 0
Truth table66%2/3
A and B
A= defined $stB= $st->size != 0
ABresult
0X0
100
111
1469 102 $t = $mon;
1470 102 $mon = ( int $st->first_item() );
1471 }
1472 else {
1473 12 $mon = ( int $this->months->first_item() );
1474 12 $year++;
1475 }
1476 114 ▶ if ( $mon != $t ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mon != $t) 17 97 114
1477 17 $cl->set(
1478 second => 0,
1479 minute => 0,
1480 hour => 0,
1481 day => 1,
1482 month => $mon
1483 );
1484
1485 17 $cl->set( year => $year );
1486 17 next ITER;
1487 }
1488 97 $cl->set( month => $mon );
1489 }
1490  
1491 # get year...................................................
1492 {
1493 114 my $year = $cl->year;
1494 97 my $t = -1;
1495  
1496 97 my $st = $this->years->tail_set( int($year) );
1497 97 ▶ if ( defined $st && $st->size() != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $st and $st->size != 0) { } 97 0 97
Condition33%1/3
defined $st and $st->size != 0
!ll&&!rl&&r
0097
MC/DC0%0/2
defined $st and $st->size != 0
defined $st $st->size != 0
Truth table33%1/3
A and B
A= defined $stB= $st->size != 0
ABresult
0X0
100
111
1498 97 $t = $year;
1499 97 $year = int( $st->first_item() );
1500 }
1501 else {
1502 0 return undef; # ran out of years...
1503 }
1504
1505 97 ▶ if ( $year != $t ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($year != $t) 0 97 97
1506 0 $cl->set(
1507 second => 0,
1508 minute => 0,
1509 hour => 0,
1510 day => 1,
1511 month => 1
1512 );
1513 0 $cl->set( year => $year );
1514 0 next ITER;
1515 }
1516
1517 97 $cl->set( year => $year );
1518 }
1519  
1520 97 $got_one = 1;
1521 } # while( !done )
1522  
1523 97 return $cl;
1524 }
1525  
1526 #* Advance the calendar to the particular hour paying particular attention
1527 #* to daylight saving problems.
1528 #*
1529 #* @param cal
1530 #* @param hour
1531  
1532 365 ▶sub set_calendar_hour {
Subroutine set_calendar_hour: called CC=3 SCAR=11.0
Pod undocumented
1533 365 my $this = shift;
1534  
1535 365 my ( $cal, $hour ) = @_;
1536  
1537 365 my $delta = 0;
1538  
1539 365 ▶ if ( $hour == 24 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hour == 24) 1 364 365
1540 1 $delta = 1;
1541 1 $hour--;
1542 }
1543  
1544 365 $cal->set( hour => $hour );
1545  
1546 365 ▶ if ( $delta > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delta > 0) 1 364 365
1547 1 $cal->add( hours => $delta );
1548 }
1549 }
1550  
1551 #=pod
1552 # * NOT YET IMPLEMENTED: Returns the time before the given time
1553 # * that the <code>CronExpression</code> matches.
1554 #=cut
1555  
1556 0 ▶sub get_time_before {
Subroutine get_time_before: not called CC=1 SCAR=6.9
Pod undocumented
1557 0 my $this = shift;
1558  
1559 0 my $end_time = shift;
1560  
1561 # TODO: implement QUARTZ-423
1562 0 return;
1563 }
1564  
1565 #=pod
1566 # * NOT YET IMPLEMENTED: Returns the final time that the
1567 # * <code>CronExpression</code> will match.
1568 #=cut
1569  
1570 0 ▶sub get_final_fire_time {
Subroutine get_final_fire_time: not called CC=1 SCAR=6.9
Pod undocumented
1571  
1572 # TODO: implement QUARTZ-423
1573 0 return;
1574 }
1575  
1576 0 ▶sub is_leap_year {
Subroutine is_leap_year: not called CC=1 SCAR=6.9
Pod undocumented
1577 0 my $this = shift;
1578  
1579 0 return DateTime->new( year => shift )->is_leap_year;
1580 }
1581  
1582 181 ▶sub getlastday_of_month {
Subroutine getlastday_of_month: called CC=1 SCAR=0.0
Pod undocumented
1583 181 my $this = shift;
1584  
1585 181 my ( $month_num, $year ) = @_;
1586  
1587 181 return DateTime->last_day_of_month( month => $month_num, year => $year )
1588 ->day;
1589 }
1590  
1591 1 1;
1592  
1593 __END__
↑ Summary Quartz/TreeSet.pm »