1Business::Hours(3)    User Contributed Perl Documentation   Business::Hours(3)
2
3
4

NAME

6       Business::Hours - Calculate business hours in a time period
7

SYNOPSIS

9         use Business::Hours;
10         my $hours = Business::Hours->new();
11
12         # Get a Set::IntSpan of all the business hours in the next week.
13         # use the default business hours of 9am to 6pm localtime.
14         $hours->for_timespan( Start => time(), End => time()+(86400*7) );
15

DESCRIPTION

17       This module is a simple tool for calculating business hours in a time
18       period.  Over time, additional functionality will be added to make it
19       easy to calculate the number of business hours between arbitrary dates.
20

USAGE

22   new
23       Creates a new Business::Hours object.  Takes no arguments.
24
25   business_hours HASH
26       Gets / sets the business hours for this object.  Takes a hash (NOT a
27       hash reference) of the form:
28
29           my %hours = (
30               0 => { Name     => 'Sunday',
31                      Start    => 'HH:MM',
32                      End      => 'HH:MM' },
33
34               1 => { Name     => 'Monday',
35                      Start    => 'HH:MM',
36                      End      => 'HH:MM' },
37               ....
38
39               6 => { Name     => 'Saturday',
40                      Start    => 'HH:MM',
41                      End      => 'HH:MM' },
42           );
43
44       Start and End times are of the form HH:MM.  Valid times are from 00:00
45       to 23:59.  If your hours are from 9am to 6pm, use Start => '9:00', End
46       => '18:00'.  A given day MUST have a start and end time OR may declare
47       both Start and End to be undef, if there are no valid hours on that
48       day.
49
50       Note that the ending time is really "what is the first minute we're
51       closed.  If you specifiy an "End" of 18:00, that means that at 6pm, you
52       are closed.  The last business second was 17:59:59.
53
54       As well, you can pass information about holidays using key 'holidays'
55       and an array reference value, for example:
56
57           $hours->business_hours(
58               0 => { Name     => 'Sunday',
59                      Start    => 'HH:MM',
60                      End      => 'HH:MM' },
61               ....
62               6 => { Name     => 'Saturday',
63                      Start    => 'HH:MM',
64                      End      => 'HH:MM' },
65
66               holidays => [qw(01-01 12-25 2009-05-08)],
67           );
68
69       Read more about holidays specification below in /"holidays ARRAY".
70
71   holidays ARRAY
72       Gets / sets holidays for this object. Takes an array where each element
73       is ether 'MM-DD' or 'YYYY-MM-DD'.
74
75       Specification with year defined may be required when a holiday matches
76       Sunday or Saturday. In many countries days are shifted in such case.
77
78       Holidays can be set via /"business_hours HASH" method as well, so you
79       can use this feature without changing your code.
80
81   for_timespan HASH
82       Takes a hash with the following parameters:
83
84       Start
85           The start of the period in question in seconds since the epoch
86
87       End The end of the period in question in seconds since the epoch
88
89       Returns a Set::IntSpan of business hours for this period of time.
90
91   between START, END
92       Returns the number of business seconds between START and END Both START
93       and END should be specified in seconds since the epoch.
94
95       Returns -1 if START or END are outside the calculated business hours.
96
97   first_after START
98       Returns START if START is within business hours.  Otherwise, returns
99       the next business second after START.  START should be specified in
100       seconds since the epoch.
101
102       Returns -1 if it can't find any business hours within thirty days.
103
104   add_seconds START, SECONDS
105       Returns a time SECONDS business seconds after START.  START should be
106       specified in seconds since the epoch.
107
108       Returns -1 if it can't find any business hours within thirty days.
109

BUGS

111       Yes, most likely.  Please report them to
112       bug-business-hours@rt.cpan.org.
113

AUTHOR

115       Jesse Vincent, jesse@cpan.org
116
118       Copyright 2003-2008 Best Practical Solutions, LLC.
119
120       This program is free software; you can redistribute it and/or modify it
121       under the same terms as Perl itself.
122
123       The full text of the license can be found in the LICENSE file included
124       with this module.
125
126
127
128perl v5.12.0                      2008-11-27                Business::Hours(3)
Impressum