blib/lib/Algorithm/Cron.pm

filter: Statementstmt 100% 152 / 152 Branchbran 94.3% 83 / 88 Conditioncond 91.6% 33 / 36 MC/DCmcdc 85.7% 18 / 21 Subroutinesub 100% 17 / 17 Podpod 66.6% 2 / 3 totaltotal 96.2% 305 / 317 CC 70 SCAR 28.3
CC
70
Cov
97%
_expand_set
28.1
next_time_field
17.0
next_time
15.0
CRAP 17.0
↑ Summary
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2012-2014 -- leonerd@leonerd.org.uk
5  
6 package Algorithm::Cron;
7  
8 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our $VERSION = '0.10';
12  
13 5 my @FIELDS = qw( sec min hour mday mon year wday );
14 5 my @FIELDS_CTOR = grep { $_ ne "year" } @FIELDS;
15  
16 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use POSIX qw( mktime strftime setlocale LC_TIME );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Time::timegm qw( timegm );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 =head1 NAME
21  
22 C<Algorithm::Cron> - abstract implementation of the F<cron(8)> scheduling
23 algorithm
24  
25 =head1 SYNOPSIS
26  
27 use Algorithm::Cron;
28  
29 my $cron = Algorithm::Cron->new(
30 base => 'local',
31 crontab => "*/10 9-17 * * *",
32 );
33  
34 my $time = time;
35 while(1) {
36 $time = $cron->next_time( $time );
37  
38 sleep( time - $time );
39  
40 print "Do something\n";
41 }
42  
43 =head1 DESCRIPTION
44  
45 Objects in this class implement a time scheduling algorithm such as used by
46 F<cron(8)>. Objects are stateless once constructed, and represent a single
47 schedule as defined by a F<crontab(5)> entry. The object implements a method
48 C<next_time> which returns an epoch timestamp value to indicate the next time
49 included in the crontab schedule.
50  
51 =head2 Crontabs
52  
53 The schedule is provided as a set of acceptable values for each field of the
54 broken-down time (as returned by C<localtime> or C<gmtime>), either in a
55 single string called C<crontab> or by a set of named strings, each taking the
56 name of a F<crontab(5)> field.
57  
58 my $cron = Algorithm::Cron->new(
59 base => 'local',
60 crontab => '0 9 * * mon-fri',
61 );
62  
63 Z<>
64  
65 my $cron = Algorithm::Cron->new(
66 base => 'local',
67 min => 0,
68 hour => 9,
69 wday => "mon-fri",
70 );
71  
72 A C<crontab> field containing a single asterisk (C<*>), or a missing named
73 field, indicates that any value here is included in the scheduled times. To
74 restrict the schedule, a value or set of values can be provided. This should
75 consist of one or more comma-separated numbers or ranges, where a range is
76 given as the start and end points, both inclusive.
77  
78 hour => "3-6"
79 hour => "3,4,5,6"
80  
81 Ranges can also be prefixed by a value to give the increment for values in
82 that range.
83  
84 min => "*/10"
85 min => "0,10,20,30,40,50"
86  
87 The C<mon> and C<wday> fields also allow symbolic month or weekday names in
88 place of numeric values. These names are always in the C locale, regardless of
89 the system's locale settings.
90  
91 mon => "mar-sep"
92  
93 wday => "mon,wed,fri"
94  
95 Specifying C<sun> as the end of a C<wday> range, or giving the numeric value
96 of C<7> is also supported.
97  
98 wday => "fri-sun"
99 wday => "5-7"
100 # Both equivalent to: wday => "0,5,6"
101  
102 As per F<cron(8)> behaviour, this algorithm looks for a match of the C<min>,
103 C<hour> and C<mon> fields, and at least one of the C<mday> or C<mday> fields.
104 If both C<mday> and C<wday> are specified, a match of either will be
105 sufficient.
106  
107 As an extension, seconds may be provided either by passing six space-separated
108 fields in the C<crontab> string, or as an additional C<sec> field. If not
109 provided it will default to C<0>. If six fields are provided, the first gives
110 the seconds.
111  
112 =head2 Time Base
113  
114 C<Algorithm::Cron> supports using either UTC or the local timezone when
115 comparing against the given schedule.
116  
117 =cut
118  
119 # mday field starts at 1, others start at 0
120 5 my %MIN = (
121 sec => 0,
122 min => 0,
123 hour => 0,
124 mday => 1,
125 mon => 0
126 );
127  
128 # These don't have to be real maxima, as the algorithm will cope. These are
129 # just the top end of the range expansions
130 5 my %MAX = (
131 sec => 59,
132 min => 59,
133 hour => 23,
134 mday => 31,
135 mon => 11,
136 wday => 6,
137 );
138  
139 5 my %MONTHS;
140 my %WDAYS;
141 # These always want to be in LC_TIME=C
142 {
143 5 my $old_loc = setlocale( LC_TIME );
144 5 setlocale( LC_TIME, "C" );
145  
146 5 %MONTHS = map { lc(strftime "%b", 0,0,0, 1, $_, 70), $_ } 0 .. 11;
147  
148 # 0 = Sun. 4th Jan 1970 was a Sunday
149 5 %WDAYS = map { lc(strftime "%a", 0,0,0, 4+$_, 0, 70), $_ } 0 .. 6;
150  
151 5 setlocale( LC_TIME, $old_loc );
152 }
153  
154 sub _expand_set
155 136 ▶{
Subroutine _expand_set: called CC=28 SCAR=33.4
156 136 my ( $spec, $kind ) = @_;
157  
158 136 ▶ return undef if $spec eq "*";
Branch: 1 branch
BranchTrueFalseTotal
if $spec eq "*" 49 87 136
159  
160 87 my @vals;
161 87 foreach my $val ( split m/,/, $spec ) {
162 88 my $step = 1;
163 88 my $end;
164  
165 88 ▶ $val =~ s{/(\d+)$}{} and $step = $1;
Branch: 1 branch
BranchTrueFalseTotal
$val =~ s[/(\d+)$][] and $step = $1 8 80 88
166  
167 88 ▶ $val =~ m{^(.+)-(.+)$} and ( $val, $end ) = ( $1, $2 );
Branch: 1 branch
BranchTrueFalseTotal
$val =~ /^(.+)-(.+)$/ and ($val, $end) = ($1, $2) 7 81 88
168 88 ▶ if( $val eq "*" ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($val eq '*') { } 7 81 88
elsif ($kind eq 'mon') { } 10 71 81
elsif ($kind eq 'wday') { } 11 60 71
169 7 ( $val, $end ) = ( $MIN{$kind}, $MAX{$kind} );
170 }
171 elsif( $kind eq "mon" ) {
172 # Users specify 1-12 but we want 0-11
173 10 ▶ defined and m/^\d+$/ and $_-- for $val, $end;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and /^\d+$/ and --$_ 8 12 20
Condition100%3/3
defined $_ and /^\d+$/
!ll&&!rl&&r
938
MC/DC100%2/2
defined $_ and /^\d+$/
defined $_ /^\d+$/
Truth table100%3/3
A and B
A= defined $_B= /^\d+$/
ABresult
0X0
100
111
174 # Convert symbolics
175 10 ▶ defined and exists $MONTHS{lc $_} and $_ = $MONTHS{lc $_} for $val, $end;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and exists $MONTHS{lc $_} and $_ = $MONTHS{lc $_} 3 17 20
Condition100%3/3
defined $_ and exists $MONTHS{lc $_}
!ll&&!rl&&r
983
MC/DC100%2/2
defined $_ and exists $MONTHS{lc $_}
defined $_ exists $MONTHS{lc $_}
Truth table100%3/3
A and B
A= defined $_B= exists $MONTHS{lc $_}
ABresult
0X0
100
111
176 }
177 elsif( $kind eq "wday" ) {
178 # Convert symbolics
179 11 ▶ defined and exists $WDAYS{lc $_} and $_ = $WDAYS{lc $_} for $val, $end;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and exists $WDAYS{lc $_} and $_ = $WDAYS{lc $_} 10 12 22
Condition100%3/3
defined $_ and exists $WDAYS{lc $_}
!ll&&!rl&&r
7510
MC/DC100%2/2
defined $_ and exists $WDAYS{lc $_}
defined $_ exists $WDAYS{lc $_}
Truth table100%3/3
A and B
A= defined $_B= exists $WDAYS{lc $_}
ABresult
0X0
100
111
180 11 ▶ $end = 7 if defined $end and $end == 0 and $val > 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $end and $end == 0 and $val > 0 1 10 11
Condition83%5/6
defined $end and $end == 0 and $val > 0
!ll&&!rl&&r
1001
defined $end and $end == 0
!ll&&!rl&&r
731
MC/DC66%2/3
defined $end and $end == 0 and $val > 0
defined $end $end == 0 $val > 0
Truth table75%3/4
A and B and C
A= defined $endB= $end == 0C= $val > 0
ABCresult
0XX0
10X0
1100
1111
181 }
182  
183 88 ▶ $val =~ m/^\d+$/ or croak "$val is unrecognised for $kind";
Branch: 1 branch
BranchTrueFalseTotal
$val =~ /^\d+$/ or croak("$val is unrecognised for $kind") 87 1 88
184 87 ▶ $end =~ m/^\d+$/ or croak "$end is unrecognised for $kind" if defined $end;
Branch: 1 branch
BranchTrueFalseTotal
if defined $end 14 73 87
Condition60%3/5
defined $end && ($end =~ /^\d+$/ || croak("$end is unrecognised for $kind"))
!ll&&!rl&&r
73140
$end =~ /^\d+$/ or croak("$end is unrecognised for $kind")
l!l
140
MC/DC0%0/2
defined $end && ($end =~ /^\d+$/ || croak("$end is unrecognised for $kind"))
defined $end $end =~ /^\d+$/
Truth table33%1/3
A && B
A= defined $endB= $end =~ /^\d+$/
ABresult
0X0
100
111
185  
186 87 push @vals, $val;
187 87 ▶ push @vals, $val while defined $end and ( $val += $step ) <= $end;
Branch: 1 branch
BranchTrueFalseTotal
defined $end and ($val += $step) <= $end and do { push @vals, $val } 52 87 139
Condition100%3/3
defined $end and ($val += $step) <= $end
!ll&&!rl&&r
731452
MC/DC100%2/2
defined $end and ($val += $step) <= $end
defined $end ($val += $step) <= $end
Truth table100%3/3
A and B
A= defined $endB= ($val += $step) <= $end
ABresult
0X0
100
111
188  
189 87 ▶ if( $kind eq "wday" && $vals[-1] == 7 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "wday" and $vals[-1] == 7) 2 85 87
Condition100%3/3
$kind eq "wday" and $vals[-1] == 7
!ll&&!rl&&r
7692
MC/DC100%2/2
$kind eq "wday" and $vals[-1] == 7
$kind eq "wday" $vals[-1] == 7
Truth table100%3/3
A and B
A= $kind eq "wday"B= $vals[-1] == 7
ABresult
0X0
100
111
190 2 ▶ unshift @vals, 0 unless $vals[0] == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $vals[0] == 0 2 0 2
191 2 pop @vals;
192 }
193 }
194  
195 86 return \@vals;
196 }
197  
198 5 ▶use constant { EXTRACT => 0, BUILD => 1, NORMALISE => 2 };
Subroutine BEGIN: called CC=1 SCAR=0.0
199 my %time_funcs = (
200 # EXTRACT BUILD NORMALISE
201 1 ▶ local => [ sub { localtime $_[0] }, \&mktime, sub { localtime mktime @_[0..5], -1, -1, -1 } ],
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
202 73 ▶ utc => [ sub { gmtime $_[0] }, \&timegm, sub { gmtime timegm @_[0..5], -1, -1, -1 } ],
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
203 );
204  
205 # Indices in time array
206 5 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
207 5 TM_SEC => 0,
208 TM_MIN => 1,
209 TM_HOUR => 2,
210 TM_MDAY => 3,
211 TM_MON => 4,
212 TM_YEAR => 5,
213 TM_WDAY => 6,
214 5 };
215  
216 =head1 CONSTRUCTOR
217  
218 =cut
219  
220 =head2 $cron = Algorithm::Cron->new( %args )
221  
222 Constructs a new C<Algorithm::Cron> object representing the given schedule
223 relative to the given time base. Takes the following named arguments:
224  
225 =over 8
226  
227 =item base => STRING
228  
229 Gives the time base used for scheduling. Either C<utc> or C<local>.
230  
231 =item crontab => STRING
232  
233 Gives the crontab schedule in 5 or 6 space-separated fields.
234  
235 =item sec => STRING, min => STRING, ... mon => STRING
236  
237 Optional. Gives the schedule in a set of individual fields, if the C<crontab>
238 field is not specified.
239  
240 =back
241  
242 =cut
243  
244 sub new
245 22 ▶{
Subroutine new: called CC=12 SCAR=24.9
Pod documented
246 22 my $class = shift;
247 22 my %params = @_;
248  
249 22 my $base = delete $params{base};
250 22 ▶ grep { $_ eq $base } qw( local utc ) or croak "Unrecognised base - should be 'local' or 'utc'";
Branch: 1 branch
BranchTrueFalseTotal
grep {$_ eq $base;} "local", "utc" or croak("Unrecognised base - should be 'local' or 'utc'") 22 0 22
251  
252 22 ▶ if( exists $params{crontab} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params{"crontab"}) 21 1 22
253 21 my $crontab = delete $params{crontab};
254 21 s/^\s+//, s/\s+$// for $crontab;
255  
256 21 my @fields = split m/\s+/, $crontab;
257 21 ▶ @fields >= 5 or croak "Expected at least 5 crontab fields";
Branch: 1 branch
BranchTrueFalseTotal
@fields >= 5 or croak("Expected at least 5 crontab fields") 20 1 21
258 20 ▶ @fields <= 6 or croak "Expected no more than 6 crontab fields";
Branch: 1 branch
BranchTrueFalseTotal
@fields <= 6 or croak("Expected no more than 6 crontab fields") 20 0 20
259  
260 20 ▶ @fields = ( "0", @fields ) if @fields < 6;
Branch: 1 branch
BranchTrueFalseTotal
if @fields < 6 16 4 20
261 20 @params{ @FIELDS_CTOR } = @fields;
262 }
263  
264 21 ▶ $params{sec} = 0 unless exists $params{sec};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"sec"} 1 20 21
265  
266 21 my $self = bless {
267 base => $base,
268 }, $class;
269  
270 21 foreach ( @FIELDS_CTOR ) {
271 122 ▶ next unless exists $params{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{$_} 1 121 122
272  
273 121 $self->{$_} = _expand_set( delete $params{$_}, $_ );
274 120 ▶ !defined $self->{$_} or scalar @{ $self->{$_} } or
Branch: 1 branch
BranchTrueFalseTotal
not defined $self->{$_} or scalar @{$self->{$_};} or croak("Require at least one value for '${_}' field") 120 0 120
Condition100%2/2
not defined $self->{$_} or scalar @{$self->{$_};}
l!l
4872
MC/DC100%1/1
not defined $self->{$_} or scalar @{$self->{$_};}
not defined $self->{$_}
Truth table100%2/2
not(A)
A= not defined $self->{$_}
Aresult
11
00
275 croak "Require at least one value for '$_' field";
276 }
277  
278 20 return $self;
279 }
280  
281 =head1 METHODS
282  
283 =cut
284  
285 =head2 @seconds = $cron->sec
286  
287 =head2 @minutes = $cron->min
288  
289 =head2 @hours = $cron->hour
290  
291 =head2 @mdays = $cron->mday
292  
293 =head2 @months = $cron->mon
294  
295 =head2 @wdays = $cron->wday
296  
297 Accessors that return a list of the accepted values for each scheduling field.
298 These are returned in a plain list of numbers, regardless of the form they
299 were specified to the constructor.
300  
301 Also note that the list of valid months will be 0-based (in the range 0 to 11)
302 rather than 1-based, to match the values used by C<localtime>, C<gmtime>,
303 C<mktime> and C<timegm>.
304  
305 =cut
306  
307 5 foreach my $field ( @FIELDS_CTOR ) {
308 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
309 27 ▶ *$field = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
310 27 my $self = shift;
311 27 ▶ @{ $self->{$field} || [] };
Condition100%2/2
$self->{$field} || []
l!l
216
MC/DC100%1/1
$self->{$field} || []
$self->{$field}
Truth table100%2/2
A
A= $self->{$field}
Aresult
11
00
312 30 };
313 }
314  
315 sub next_time_field
316 978 ▶{
Subroutine next_time_field: called CC=17 SCAR=28.3
Pod undocumented
317 978 my $self = shift;
318 978 my ( $t, $idx ) = @_;
319  
320 978 my $funcs = $time_funcs{$self->{base}};
321  
322 978 ▶ my $spec = $self->{ $FIELDS[$idx] } or return 1;
Branch: 1 branch
BranchTrueFalseTotal
my $spec = $$self{$FIELDS[$idx]} or return 1 713 265 978
323  
324 713 my $old = $t->[$idx];
325 713 my $new;
326  
327 713 ▶ $_ >= $old and $new = $_, last for @$spec;
Branch: 1 branch
BranchTrueFalseTotal
$_ >= $old and $new = $_, last 533 295 828
328  
329 # wday field is special. We can't alter it directly; any changes to it have
330 # to happen via mday
331 713 ▶ if( $idx == TM_WDAY ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx == 6) { } 103 610 713
332 103 $idx = TM_MDAY;
333 # Adjust $new by the same delta
334 103 ▶ $new = $t->[TM_MDAY] + $new - $old if defined $new;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new 87 16 103
335 103 $old = $t->[TM_MDAY];
336  
337 103 ▶ if( !defined $new ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $new) { } 16 87 103
elsif ($new > $old) { } 8 79 87
338 # Next week
339 16 $t->[$_] = $MIN{$FIELDS[$_]} for TM_SEC .. TM_HOUR;
340 # Add more days, such that we hit the next occurance of $spec->[0]
341 16 $t->[TM_MDAY] += $spec->[0] + 7 - $t->[TM_WDAY];
342  
343 16 @$t = $funcs->[NORMALISE]->( @$t );
344  
345 16 return 0;
346 }
347 elsif( $new > $old ) {
348 8 $t->[$_] = $MIN{$FIELDS[$_]} for TM_SEC .. $idx-1;
349 }
350 }
351 else {
352 610 ▶ if( !defined $new ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $new) { } 164 446 610
elsif ($new > $old) { } 70 376 446
353 # Rollover
354 164 $t->[$_] = $MIN{$FIELDS[$_]} for TM_SEC .. $idx-1;
355 164 $t->[$idx] = $spec->[0];
356 164 $t->[$idx+1]++;
357  
358 164 @$t = $funcs->[NORMALISE]->( @$t );
359  
360 164 return 0;
361 }
362 elsif( $new > $old ) {
363 # Next field; reset
364 70 $t->[$_] = $MIN{$FIELDS[$_]} for TM_SEC .. $idx-1;
365 }
366 }
367  
368 533 $t->[$idx] = $new;
369  
370 # Detect rollover of month and reset to next month
371 533 my $was_mon = $t->[TM_MON];
372  
373 533 @$t = $funcs->[NORMALISE]->( @$t );
374  
375 533 ▶ if( $idx == TM_MDAY and $was_mon != $t->[TM_MON] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx == 3 and $was_mon != $t->[4]) 6 527 533
Condition100%3/3
$idx == 3 and $was_mon != $t->[4]
!ll&&!rl&&r
3511766
MC/DC100%2/2
$idx == 3 and $was_mon != $t->[4]
$idx == 3 $was_mon != $t->[4]
Truth table100%3/3
A and B
A= $idx == 3B= $was_mon != $t->[4]
ABresult
0X0
100
111
376 6 $t->[$_] = 0 for TM_SEC .. TM_HOUR;
377 6 $t->[TM_MDAY] = 1;
378  
379 6 @$t = $funcs->[NORMALISE]->( @$t );
380  
381 6 return 0;
382 }
383  
384 527 return 1;
385 }
386  
387 =head2 $time = $cron->next_time( $start_time )
388  
389 Returns the next scheduled time, as an epoch timestamp, after the given
390 timestamp. This is a stateless operation; it does not change any state stored
391 by the C<$cron> object.
392  
393 =cut
394  
395 sub next_time
396 74 ▶{
Subroutine next_time: called CC=15 SCAR=27.1
Pod documented
397 74 my $self = shift;
398 74 my ( $time ) = @_;
399  
400 74 my $funcs = $time_funcs{$self->{base}};
401  
402 # Always need to add at least 1 second
403 74 my @t = $funcs->[EXTRACT]->( $time + 1 );
404  
405 245 ▶RESTART:
Branch: 1 branch
BranchTrueFalseTotal
$self->next_time_field(\@t, 4) or goto RESTART 240 5 245
406 $self->next_time_field( \@t, TM_MON ) or goto RESTART;
407  
408 240 ▶ if( defined $self->{mday} and defined $self->{wday} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $self->{'mday'} and defined $self->{'wday'}) { } 29 211 240
elsif (defined $self->{'mday'}) { } 84 127 211
elsif (defined $self->{'wday'}) { } 74 53 127
Condition100%3/3
defined $self->{"mday"} and defined $self->{"wday"}
!ll&&!rl&&r
1278429
MC/DC100%2/2
defined $self->{"mday"} and defined $self->{"wday"}
defined $self->{"mday"} defined $self->{"wday"}
Truth table100%3/3
A and B
A= defined $self->{"mday"}B= defined $self->{"wday"}
ABresult
0X0
100
111
409 # Now it gets tricky because cron allows a match of -either- mday or wday
410 # rather than requiring both. So we'll work out which of the two is sooner
411 29 my $next_time_by_wday;
412 29 my @wday_t = @t;
413 29 my $wday_restart = 0;
414 29 ▶ $self->next_time_field( \@wday_t, TM_WDAY ) or $wday_restart = 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->next_time_field(\@wday_t, 6) or $wday_restart = 1 24 5 29
415 29 $next_time_by_wday = $funcs->[BUILD]->( @wday_t );
416  
417 29 my $next_time_by_mday;
418 29 my @mday_t = @t;
419 29 my $mday_restart = 0;
420 29 ▶ $self->next_time_field( \@mday_t, TM_MDAY ) or $mday_restart = 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->next_time_field(\@mday_t, 3) or $mday_restart = 1 15 14 29
421 29 $next_time_by_mday = $funcs->[BUILD]->( @mday_t );
422  
423 29 ▶ if( $next_time_by_wday > $next_time_by_mday ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_time_by_wday > $next_time_by_mday) { } 4 25 29
424 4 @t = @mday_t;
425 4 ▶ goto RESTART if $mday_restart;
Branch: 1 branch
BranchTrueFalseTotal
if $mday_restart 0 4 4
426 }
427 else {
428 25 @t = @wday_t;
429 25 ▶ goto RESTART if $wday_restart;
Branch: 1 branch
BranchTrueFalseTotal
if $wday_restart 4 21 25
430 }
431 }
432 elsif( defined $self->{mday} ) {
433 84 ▶ $self->next_time_field( \@t, TM_MDAY ) or goto RESTART;
Branch: 1 branch
BranchTrueFalseTotal
$self->next_time_field(\@t, 3) or goto RESTART 74 10 84
434 }
435 elsif( defined $self->{wday} ) {
436 74 ▶ $self->next_time_field( \@t, TM_WDAY ) or goto RESTART;
Branch: 1 branch
BranchTrueFalseTotal
$self->next_time_field(\@t, 6) or goto RESTART 63 11 74
437 }
438  
439 215 foreach my $idx ( TM_HOUR, TM_MIN, TM_SEC ) {
440 517 ▶ $self->next_time_field( \@t, $idx ) or goto RESTART;
Branch: 1 branch
BranchTrueFalseTotal
$self->next_time_field(\@t, $idx) or goto RESTART 376 141 517
441 }
442  
443 74 return $funcs->[BUILD]->( @t );
444 }
445  
446 =head1 AUTHOR
447  
448 Paul Evans <leonerd@leonerd.org.uk>
449  
450 =cut
451  
452 5 0x55AA;
↑ Summary