Chapter 1 of my adventure with the Remedy team is already proving fun…
My first task is to provide a report to Jim Sabol on CSC turnaround times, in terms of business hours, on Remedy cases that often span days… and the need to exclude after-hours, weekends, holidays and other office-closed days in the tally of hours. Bryan had tackled this problem at one point in VB, but a reusable Perl solution was desirable for both Remedy reporting and other applications that need to be business-day-aware (such as our SLA ‘Contracts’ app).
As usual I didn’t regret asking Paul Sand if he had ever needed a similar solution and he pointed me to the awesome Date::Manip module on CPAN. This module can be given a config file wherein you define the hours of your organization’s work day, holidays and other office-closed days, etc., after which much of the heavy lifting of getting deltas (time differences between two given dates) is done for you.
As a means of including an always-fresh UNH specific config file in a distribution, I created the config file and a UNH::Cal package and committed them to Subversion. The UNH::Cal package itself is somewhat superfluous, as Date::Manip could be called directly, but by wrapping it in UNH::Cal I can make calls that are (perhaps more verbose than bare Date::Manip function calls, but) to me, self-documenting:
$date = UNH::Cal::Date_NextWorkDay($date,$off [,$time]);
I included some POD documentation for this little wrapper module called UNH::Cal.