| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Cron::Toolkit::Pattern::Nth; |
|
2
|
2
|
|
|
2
|
|
14
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
116
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
148
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use parent 'Cron::Toolkit::Pattern'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
35
|
|
|
5
|
2
|
|
|
2
|
|
168
|
use Cron::Toolkit::Utils qw(:all); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1253
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
|
8
|
9
|
|
|
9
|
0
|
51
|
my ($class, %args) = @_; |
|
9
|
9
|
|
|
|
|
46
|
my $self = $class->SUPER::new(%args); |
|
10
|
9
|
|
|
|
|
24
|
$self->{dow} = $args{dow}; |
|
11
|
9
|
|
|
|
|
22
|
$self->{nth} = $args{nth}; |
|
12
|
9
|
|
|
|
|
29
|
return $self; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub type { |
|
16
|
429
|
|
|
429
|
0
|
787
|
return 'nth'; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub match { |
|
20
|
363
|
|
|
363
|
0
|
431
|
my ($self, $value, $tm) = @_; |
|
21
|
363
|
|
|
|
|
478
|
my $target_dow = $self->{dow}; |
|
22
|
363
|
|
|
|
|
401
|
my $nth = $self->{nth}; |
|
23
|
363
|
|
|
|
|
575
|
my $dom = $tm->day_of_month; |
|
24
|
|
|
|
|
|
|
|
|
25
|
363
|
|
|
|
|
428
|
my $count = 0; |
|
26
|
363
|
|
|
|
|
610
|
for my $d (1 .. $dom - 1) { |
|
27
|
5506
|
100
|
|
|
|
11791
|
$count++ if $tm->with_day_of_month($d)->day_of_week == $target_dow; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
363
|
100
|
|
|
|
1206
|
return 0 unless $tm->day_of_week == $target_dow; |
|
31
|
59
|
|
|
|
|
231
|
return $count + 1 == $nth; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub to_english { |
|
35
|
9
|
|
|
9
|
0
|
26
|
my ($self) = @_; |
|
36
|
9
|
|
|
|
|
68
|
my $day = $DAY_NAMES{ $self->{dow} }; |
|
37
|
9
|
|
|
|
|
37
|
my $nth = num_to_ordinal( $self->{nth} ); |
|
38
|
9
|
|
|
|
|
78
|
return "on the $nth $day"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |