[Bps-public-commit] r17037 - Business-Hours/trunk/lib/Business

ruz at bestpractical.com ruz at bestpractical.com
Thu Nov 27 17:46:57 EST 2008


Author: ruz
Date: Thu Nov 27 17:46:57 2008
New Revision: 17037

Modified:
   Business-Hours/trunk/lib/Business/Hours.pm

Log:
* document holidays

Modified: Business-Hours/trunk/lib/Business/Hours.pm
==============================================================================
--- Business-Hours/trunk/lib/Business/Hours.pm	(original)
+++ Business-Hours/trunk/lib/Business/Hours.pm	Thu Nov 27 17:46:57 2008
@@ -114,7 +114,24 @@
 
 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. 
+The last business second was 17:59:59.
+
+As well, you can pass information about holidays using key 'holidays' and
+an array reference value, for example:
+
+    $hours->business_hours(
+        0 => { Name     => 'Sunday',
+               Start    => 'HH:MM',
+               End      => 'HH:MM' },
+        ....
+        6 => { Name     => 'Saturday',
+               Start    => 'HH:MM',
+               End      => 'HH:MM' },
+
+        holidays => [qw(01-01 12-25 2009-05-08)],
+    );
+
+Read more about holidays specification below in L</"holidays ARRAY"|holidays>.
 
 =cut
 
@@ -127,6 +144,20 @@
     return %{ $self->{'business_hours'} };
 }
 
+=head2 holidays ARRAY
+
+Gets / sets holidays for this object. Takes an array
+where each element is ether 'MM-DD' or 'YYYY-MM-DD'.
+
+Specification with year defined may be required when a holiday
+matches Sunday or Saturday. In many countries days are shifted
+in such case.
+
+Holidays can be set via L</"business_hours HASH"|business_hours> method
+as well, so you can use this feature without changing your code.
+
+=cut
+
 sub holidays {
     my $self = shift;
     if ( @_ ) {
@@ -266,7 +297,6 @@
     # hours intspan. (Because we want to trim any business hours that fall
     # outside the business period)
 
-    # TODO: Remove any holidays from the business hours
     if ( my @holidays = $self->holidays ) {
         my $start_year = $year;
         my $end_year = (localtime $args{'End'})[5];



More information about the Bps-public-commit mailing list