[Rt-devel] Using Business::Hours to set the CF Response Time

Richard Fojta rfojta at gmail.com
Tue Aug 28 11:52:48 EDT 2007


Hello,
documentation says

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 is outside the calculated business hours

See http://search.cpan.org/dist/Business-Hours/lib/Business/Hours.pm
and use method business_hours. Documenation is copied beneath.

Set the business_hours.
for this Business::Hours object. Takes a hash of the form :

{ 0 => { Name => 'Sunday', Start => 'HH:MM', End => 'HH:MM'},

    1 => { Name => 'Monday',
            Start => 'HH:MM',
               End => 'HH:MM'},
    ....

    6 => { Name => 'Saturday',
            Start => 'HH:MM',
               End => 'HH:MM'},
    };

    Start and end times are of the form HH:MM.  Valid times are
    from 00:00 to 23:59.  If your hours are from 9am to 6pm, use
    Start => '9:00', End => '18:00'.  A given day MUST have a start
    and end time OR may declare both Start and End to be undef, if
    there are no valid hours on that day.

    Note that the ending time is really "what is the first minute we're closed.
    If you specifiy an "End" of 18:00, that means that at 6pm, you are closed.
    The last business second was 17:59:59. \

Greetings.
Richard Fojta

On 8/28/07, Anders Ekstrand <Anders.Ekstrand at drutt.com> wrote:
> Hi all,
>
> I was up to using a scrip to automatically set my custom field "Response
> Time" to a proper value, when sending the first response to a customer
> in a ticket.
>
> I found nothing on the RT Wiki that I could use, so I installed
> Business::Hours and Set::IntSpan and tried the following scrip on my RT
> 3.6.5RC2 installation:
>
>
>
> use Business::Hours;
>
> my $BusinessHours = Business::Hours->new();
> my $Ticket = $self->TicketObj;
> my $cfResponseTime = new RT::CustomField( $RT::SystemUser );
> my $responseTime = $Ticket->FirstCustomFieldValue( 'Response Time' );
>
> if ( !$responseTime ) {
>
>   my $createdTime = $Ticket->CreatedObj->Unix;
>   my $responseTime = $BusinessHours->between( $createdTime, time() );
>
>   $cfResponseTime->LoadByNameAndQueue ( Name=>'Response Time', Queue=>0
> );
>   $Ticket->AddCustomFieldValue( Field => $cfResponseTime, Value =>
> $responseTime );
> }
>
> return(1);
>
>
>
> Unfortunately, the "between" method only returns -1 for me...
>
> Anybody that has a hint regarding what I could have missed here?
>
>
> Best Regards - Anders Ekstrand
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
>


More information about the Rt-devel mailing list