Modification of RT-Extension-SLA

Hi there,

another question about RT-Extension-SLA. First of all i must tell you that I´m
really a starter with Perl. I have to modify the Extension because we need some
kind of “floating” SLA.

When a ticket arrives before 12.00 am it´s necessary to set SLA to next day
23:59:59, if it arrives later than 12.00 am i need to set it two days later

I used the function SetToMidnight with the due date as Argument. So I´ve tried
to get the difference between these two dates, if it is more than 12 hours than
the ticket was created later than 12 am, if less, earlier than 12 am.

Here´s some code I´ve started with, so maybe you can tell me how I can finish it

use strict;
use warnings;

package RT::Action::SLA_SetFloatingDue;
use RT::Date;
use Time::Local;

use base qw(RT::Action::SLA);

=head2 Prepare

Checks if the ticket has service level defined.


sub Prepare {
my $self = shift;

unless ( $self->TicketObj->FirstCustomFieldValue('SLA') ) {
    $RT::Logger->error('SLA::SetDue scrip has been applied to ticket #'
        . $self->TicketObj->id . ' that has no SLA defined');
    return 0;

return 1;


=head2 Commit

Set the Due date accordingly to SLA.


sub Commit {

    my $self = shift;

    my $ticket = $self->TicketObj;

    my $due=$ticket->DueObj;

    my $midnight = RT::Date::SetToMidnight($due);
    $midnight = $midnight->Unix;
    $due = $due->Unix;
    my $diff = RT::Date::Diff($due,$midnight);
    $RT::Logger->debug("Midnight" . $midnight);

    # This is only for test reasons, later we have to change it to correct

return $self->TicketObj->SetDue($due);

And this is the error message :

[error]: Scrip Commit 25 died. - Undefined subroutine
&RT::Action::SLA_SetFloatingDue::Diff called at /opt/rt3/local/plugins/RT-Exten
sion-SLA/lib/RT/Action/ line 47.