perlrt

How to fix Perl Business::Hours Bad order 2 critical error?


We have Request Tracker 4.4.3. There we have an automated script that uses Business::Hours distribution. Here's the essential part:

sub IsApplicable {
    my $self = shift;
    my $bhours = $self->BusinessHours;
    my $ticket = $self->TicketObj;
    my $due = $ticket->DueObj->Unix;
    my $bseconds = $bhours->between( time(), $due );
}

Sometimes we get an error to stderr:

[23406] [Wed Mar 13 07:40:09 2019] [critical]: Set::IntSpan::_copy_run_list: Bad order 2: 1552462809-1552462694
 at /usr/local/share/perl5/Business/Hours.pm line 269. (/opt/rt4/bin/../lib/RT.pm:408)
Set::IntSpan::_copy_run_list: Bad order 2: 1552462809-1552462694
 at /usr/local/share/perl5/Business/Hours.pm line 269.

It doesn't seem to make sense, 1552462809-1552462694 pretty much evaluates to 115.

How to analyze/fix this error?


Solution

  • According to documentation Business::Hours:

    between START, END

    Returns the number of business seconds between START and END Both START and END should be specified in seconds since the epoch.

    Returns -1 if START or END are outside the calculated business hours.

    So probably END must be greater than START