Changed logic of inverted interval management

This commit is contained in:
Jose Gonzalez 2020-02-25 17:45:07 +01:00
parent d1663cd242
commit 816123f6ef
1 changed files with 5 additions and 9 deletions

View File

@ -2621,7 +2621,7 @@ sub cron_next_execution {
$nex_time = cron_next_execution_date ($cron, $nex_time, 0);
}
return $nex_time - time();
return $nex_time - $cur_time;
}
###############################################################################
@ -2652,7 +2652,7 @@ sub cron_check_interval {
if ($down < $up) {
return 0 if ($elem_curr_time < $down || $elem_curr_time > $up);
} else {
return 0 if ($elem_curr_time > $down || $elem_curr_time < $up);
return 0 if ($elem_curr_time < $down && $elem_curr_time > $up);
}
return 1;
@ -2676,15 +2676,11 @@ sub cron_next_execution_date {
}
}
# Get current time
if (! defined ($cur_time)) {
$cur_time = time();
}
# Check if current time + interval is on cron too
my $nex_time = $cur_time + $interval;
my ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year)
= (localtime ($nex_time))[1, 2, 3, 4, 5];
my @cron_array = ($min, $hour, $mday, $mon);
my @curr_time_array = ($cur_min, $cur_hour, $cur_mday, $cur_mon);
return ($nex_time) if cron_is_in_cron(\@cron_array, \@curr_time_array) == 1;
@ -2821,7 +2817,7 @@ sub cron_is_in_cron {
# * should returns floor data.
# 5 should returns 5.
# 10-55 should returns 10.
# 55-10 should retunrs floor data.
# 55-10 should returns elem_down.
################################################################################
sub cron_get_next_time_element {
# Default floor data is 0
@ -2829,7 +2825,7 @@ sub cron_get_next_time_element {
$floor_data = 0 unless defined($floor_data);
my ($elem_down, $elem_up) = cron_get_interval ($curr_element);
return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up))
return ($elem_down eq '*')
? $floor_data
: $elem_down;
}