BusinessHours - An object that calculates business days and hours
use BusinessHours; use DateTime; my $datetime1=DateTime->new(year=>2007,month=>10,day=>15); my $datetime2 = DateTime->now; my $testing = BusinessHours->new(datetime1=>$datetime1, datetime2=>$datetime2, worktiming=>[9,18], # 9 am to 6 om weekends=>[6,7], #saturday , sunday holidays=>["2007-10-31",2007-12-24] holidayfile=>'holidaylist' #holidaylist is a text file #with each date in a new line #in the format yyyy-mm-dd ); print $testing->getdays."\n"; # the total business days print $testing->gethours; # the total business hours
BusinessHours a class for caculating the business hours between two DateTime objects.It can be useful in situations like escalation where an action has to happen after a certain number of business hours.
Create an instance of the class with the two required datetime objects. and use the methods to get the business hours or days.
This class method accepts the following parameters in the hash format.
datetime1 => Starting Date datetime2 => Ending Date worktimings => A list reference with two values.Starting and ending hour of the day. Defaults to [9,18] weekends => A list reference with values of the days that must be considered as non-working in a week.Defaults to [6,7] - Saturday , Sunday. holidays => A list reference with holiday dates. holidayfile => The name of a file from which predefined holidays can be excluded from business days /hours calculation. Defaults to no file.
This class has two methods.
Returns the number of business days
Returns the number of business hours.
Antano Solar John<email@example.com>
Copyright (c) 2007 Antano Solar John. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.