Customizing Business::Hours

Hi all,

I’m not sure this is the right place for discussions about perl modules not
part of RT’s codebase, but since Business::Hours is strictly related to
SLA, and SLA is strictly related to RT… Here I am.

Long story short, I added a few subs to Hours.pm in order to have the
possibility to set the next business day as the due date. The main sub is *
end_of_next_business_day*

One concern I have is about the timezone. Simply I didn’t mind about it,
for, as far as I can see, Business::Hours’ author didn’t mind as well. Is
it alright?

Please, test it if you like, and give me some feedback.

If interested, I can show you how to integrate my custom Hours.pm with
RT::Extension::SLA

Regards

Alberto Scotto

skype:dasgazzo

Hours.pm (18.7 KB)

Hi,

A few comments:

  1. there should be empty line between POD and code

  2. The following can be written in one line “my $t = shift || time;”:

⋅⋅⋅⋅⋅⋅⋅my $t = shift;
⋅⋅⋅⋅⋅⋅⋅
⋅⋅⋅⋅⋅⋅⋅unless ( $t ) {
⋅⋅⋅⋅⋅⋅⋅ ⋅⋅⋅⋅⋅⋅⋅$t = time;
⋅⋅⋅⋅⋅⋅⋅}

  1. I would prefer 4 spaces rather than tabs, but can convert it before
    applying

  2. all commented code should be deleted before it goes into repository

  3. in the following line $end can be “my $end = $start+246060” rather
    than function call:

my $end = timelocal_nocheck(59,59,23,@t_array[3…5]);

  1. bday_end has problems if business day spans over midnight

  2. bday_end needs better name without shortings

  3. again is_business_day_after and is_business_day suffer from assumption
    that business day can not span over midnight.

As far as I recall in the latest version we support 24/7 setups with Start
=> 06:00, End => 06:00. At least I recall doing something about business
hours spanning over midnight.

To be included it really need tests.

Some comments below.

Hi all,

I’m not sure this is the right place for discussions about perl modules
not part of RT’s codebase, but since Business::Hours is strictly related to
SLA, and SLA is strictly related to RT… Here I am.

Not a bad place.

Long story short, I added a few subs to Hours.pm in order to have the
possibility to set the next business day as the due date. The main sub is
end_of_next_business_day

I think main sub is very specific for your use case. Instead I would prefer
last_after method that is similar to first_after.

One concern I have is about the timezone. Simply I didn’t mind about it,

for, as far as I can see, Business::Hours’ author didn’t mind as well. Is
it alright?

The module uses localtime so timezone can be controlled from outside by
changing TZ variable and calling POSIX::tzset. There is experimental code
in SLA repository to deal with multiple timezones.

Please, test it if you like, and give me some feedback.

If interested, I can show you how to integrate my custom Hours.pm with
RT::Extension::SLA

Regards

Alberto Scotto

skype:dasgazzo


List info:
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel

Best regards, Ruslan.