Skip to content

Commit

Permalink
Fix infinite loop in [datetime] when subtracting business days.
Browse files Browse the repository at this point in the history
  • Loading branch information
racke committed Sep 17, 2010
1 parent c156704 commit 9db0db5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions global/datetime.tag
Expand Up @@ -166,10 +166,19 @@ sub {
if ($scope eq 'days') {
$from_dt->add(days => $amount);
} elsif ($scope eq 'business_days') {
my $incr;

if ($function eq 'sub') {
$incr = -1;
}
else {
$incr = 1;
}

while($amount){
$from_dt->add(days => 1);
$from_dt->add(days => $incr);
if($from_dt->day_of_week() < 6){
$amount--;
$amount -= $incr;
}
}
} elsif ($scope eq 'weeks') {
Expand Down

0 comments on commit 9db0db5

Please sign in to comment.