Index: /shepherd
===================================================================
--- /shepherd (revision 123)
+++ /shepherd (revision 124)
@@ -284,9 +284,9 @@
 			 query_config($grabber, 'option_days_offset') .
 			 " " .
-			 ($timeslice->{start} - 1);
+			 $timeslice->{start};
 	    }
 
-	    my $n = $timeslice->{stop};
-	    if ($timeslice->{start} != 1 
+	    my $n = $timeslice->{stop} + 1;
+	    if ($timeslice->{start} != 0 
 		    and 
 		!query_config($grabber, 'option_offset_eats_days'))
@@ -326,4 +326,5 @@
 	if ((defined $opt->{dontcallgrabbers}) && ($opt->{dontcallgrabbers})) {
 	    printf "SHEPHERD: not calling grabber because of --dontcallgrabbers option, but will instead use existing $output\n";
+	    print "SHEPHERD: would have called: $comm\n" if ($debug);
  	} else {
 	    print "SHEPHERD: Excuting command: $comm\n";
@@ -553,4 +554,6 @@
 }
 
+# Return 1 if the grabber can provide data for this channel,
+# else 0.
 sub supports_channel
 {
@@ -572,10 +575,15 @@
 }
 
+# Returns 0 if the grabber can't provide data for this day,
+# 1 if it can reliably, and 0.5 if it can unreliably.
+#
+# Note that in grabber .confs, a max_days of 7 means the
+# grabber can retrieve data for today plus 6 days.
 sub supports_day
 {
     my ($grabber, $day) = @_;
 
-    return 0 unless ($day <= query_config($grabber, 'max_days'));
-    return 0.5 if ($day > query_config($grabber, 'max_reliable_days'));
+    return 0 unless ($day < query_config($grabber, 'max_days'));
+    return 0.5 if ($day >= query_config($grabber, 'max_reliable_days'));
     return 1;
 }
@@ -597,5 +605,5 @@
     foreach my $day (keys %$missing)
     {
-	my $date = substr(DateCalc("today", "+ " . ($day - 1) . " days"), 0, 8);
+	my $date = substr(DateCalc("today", "+ $day days"), 0, 8);
 	foreach my $ch (@{$missing->{$day}})
 	{
@@ -642,4 +650,5 @@
     {
 	print "Need data for days " . join(", ", sort keys %$missing) . ".\n";
+	print Dumper($missing);
     }
     return $missing;
@@ -648,6 +657,6 @@
 # Takes a hash of what's missing in the format:
 #   { '1' => [ 'ABC', 'SBS' ], '2' => [ 'ABC' ], ... }
-# and sets $timeslice to the biggest 'slice' of that.
-# For example, the biggest slice of the above is days 1 -2 of ABC.
+# and returns the largest timeslice of that. For example, 
+# the biggest slice of the above is days 1 -2 of ABC.
 sub calculate_best_timeslice
 {
@@ -656,9 +665,9 @@
     my ($overlap, $a);
     my $slice = { 'chandays' => 0 };
-    foreach my $day (1 .. $days)
+    foreach my $day (0 .. $days-1)
     {
 	consider_slice($slice, $day, $day, @{$missing->{$day}});
 	$overlap = $missing->{$day};
-	foreach my $nextday (($day + 1) .. $days)
+	foreach my $nextday (($day + 1) .. $days-1)
 	{
 	    last unless ($missing->{$nextday});
@@ -739,5 +748,5 @@
     foreach my $day (keys %$h)
     {
-	my $date = substr(DateCalc("today", "+ " . ($day - 1) . " days"), 0, 8);
+	my $date = substr(DateCalc("today", "+ $day days"), 0, 8);
 	foreach my $ch (@{$h->{$day}})
 	{
@@ -1347,5 +1356,4 @@
 	}
     }
-
 }
 
@@ -1906,4 +1914,5 @@
     set_order(1,$order);
 
+    print "\n";
     show_channels();
     unless(ask_boolean("\nCreate configuration file?"))
