[Bps-public-commit] r15198 - in Business-Hours/trunk: lib/Business t

trs at bestpractical.com trs at bestpractical.com
Fri Aug 15 15:57:23 EDT 2008


Author: trs
Date: Fri Aug 15 15:57:03 2008
New Revision: 15198

Modified:
   Business-Hours/trunk/   (props changed)
   Business-Hours/trunk/lib/Business/Hours.pm
   Business-Hours/trunk/t/1-business-hours.t

Log:
 r39315 at zot:  tom | 2008-08-15 15:56:53 -0400
 Make between work even if the user hasn't called for_timespan yet (which calculates our spans for us)


Modified: Business-Hours/trunk/lib/Business/Hours.pm
==============================================================================
--- Business-Hours/trunk/lib/Business/Hours.pm	(original)
+++ Business-Hours/trunk/lib/Business/Hours.pm	Fri Aug 15 15:57:03 2008
@@ -285,6 +285,13 @@
     my $start = shift;
     my $end   = shift;
 
+    if ( not defined $self->{'start'} or not defined $self->{'end'} ) {
+        # We haven't calculated our sets yet, so let's do that for the
+        # user now, assuming they want to use the same start and end
+        # times
+        $self->for_timespan( Start => $start, End => $end );
+    }
+
     if ( $start < $self->{'start'} ) {
         return (-1);
     }

Modified: Business-Hours/trunk/t/1-business-hours.t
==============================================================================
--- Business-Hours/trunk/t/1-business-hours.t	(original)
+++ Business-Hours/trunk/t/1-business-hours.t	Fri Aug 15 15:57:03 2008
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use Test::More tests => 11;
+use Test::More tests => 14;
 
 BEGIN { use_ok 'Business::Hours' }
 
@@ -16,6 +16,16 @@
     is(cardinality $hours_span, (45 * 60 * 60));
 }
 
+{
+    my $hours = Business::Hours->new();
+    is(ref($hours), 'Business::Hours');
+    # how many business hours were there in the first week.
+    my $seconds = $hours->between( 0, ( (86400 * 7) - 1 ) );
+    ok( $seconds, "Got seconds" );
+
+    # Are there 45 working hours
+    is( $seconds, (45 * 60 * 60) );
+}
 
 {
     my $hours = Business::Hours->new();



More information about the Bps-public-commit mailing list