From 0720271cb317a07d0e08bc3512acfa038e8054dc Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 7 Feb 2019 12:05:50 +0100 Subject: [PATCH] TT#52359 consider negative DateTime::Duration / 6.5 Change-Id: I1f5c4885196b0179350ec4a258712afb29a7c27b (cherry picked from commit c58bf4ed458fb989a10a1a06f005f26f84e45f1b) --- lib/NGCP/Cleanup.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/NGCP/Cleanup.pm b/lib/NGCP/Cleanup.pm index 56dc43b..061ee96 100755 --- a/lib/NGCP/Cleanup.pm +++ b/lib/NGCP/Cleanup.pm @@ -352,15 +352,15 @@ sub update_partitions { $dt_max->add(months => 1); $dt_max->truncate(to => 'month'); my $dt_diff = $dt_max-$dt_min; - my $months = $dt_diff->years*12+$dt_diff->months; + my $months = ($dt_diff->years*12+$dt_diff->months) * ($dt_diff->is_negative() ? -1 : 1); $self->debug(sprintf "table=%s checking start=%s end=%s", $table, $dt_min->strftime('%Y-%m'), $dt_max->strftime('%Y-%m')); if ($months >= $MAX_PARTITIONS) { die sprintf "%s%s", - "Cannot update partitions for table=$table,", - "the gap between min/max record is too large (more than 24 months)."; + "Cannot update partitions for table=$table, ", + "the gap between max record time and min record time is too large (more than 24 months)."; } if ($self->check_partition_exists($table, 'pmax')) { # already partitionined