Index: trunk/tools/czarplot.pl
===================================================================
--- trunk/tools/czarplot.pl	(revision 28704)
+++ trunk/tools/czarplot.pl	(revision 28707)
@@ -17,4 +17,6 @@
 my $save_temps = undef;
 my $interval = undef;
+my $begin = undef;
+my $end = undef;
 my $verbose = undef;
 my $histogram = undef;
@@ -26,4 +28,6 @@
         "stage|s=s" => \$stage,
         "interval|i=s" => \$interval,
+        "begin|b=s" => \$begin,
+        "end|e=s" => \$end,
         "histogram|h" => \$histogram,
         "timeseries|t" => \$timeSeries,
@@ -48,4 +52,10 @@
     print "* OPTIONAL: choose an interval     -i <'1 hour'|'1 day'|etc>   (default=interval since 7am this morning)\n";
 } 
+if (!$begin) {
+    print "* OPTIONAL: choose a begin time    -d <datetime>               (default=7am this morning)\n";
+} 
+if (!$end) {
+    print "* OPTIONAL: choose an end time     -e <datetime>               (default=now)\n";
+} 
 
 print "\n";
@@ -63,12 +73,13 @@
 my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
 
-my $toTime = $czarDb->getNowTimestamp();
-my $fromTime = undef;
+# sort out times
+if (!$end) {$end = $czarDb->getNowTimestamp();}
+if (!$begin) {
+    if ($interval) {$begin = $czarDb->getIntervalInPast($interval);}
+    else {$begin =  strftime('%Y-%m-%d 07:00',localtime);}
+}
 
-if ($interval) {$fromTime = $czarDb->getIntervalInPast($interval);}
-else {$fromTime =  strftime('%Y-%m-%d 07:00',localtime);}
-
-if ($histogram) {plotHistogram($label, $fromTime, $toTime);}
-if ($timeSeries) {plotTimeSeries($label, $stage, $fromTime, $toTime); }
+if ($histogram) {plotHistogram($label, $begin, $end);}
+if ($timeSeries) {plotTimeSeries($label, $stage, $begin, $end); }
 
 ###########################################################################
@@ -78,5 +89,5 @@
 ###########################################################################
 sub plotTimeSeries {
-    my ($label, $selectedStage, $fromTime, $toTime) = @_;
+    my ($label, $selectedStage, $beginTime, $endTime) = @_;
 
     my ($minX, $maxX, $minY, $maxY, $timeDiff);
@@ -93,9 +104,9 @@
     my %gnuplotFiles;
     foreach $stage (@{$stages}) {
-        $gnuplotFiles{$stage} = $czarDb->createTimeSeriesData($save_temps, $label, $stage, $fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);
+        $gnuplotFiles{$stage} = $czarDb->createTimeSeriesData($save_temps, $label, $stage, $beginTime, $endTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);
     }
 
-    if (!$selectedStage) {$gnuplot->plotAllStagesTimeSeries($label, $fromTime, $toTime, $maxX, $minX, $maxY, $minY, $timeDiff, \%gnuplotFiles);}
-    else {$gnuplot->plotSingleTimeSeries($gnuplotFiles{$selectedStage}, $selectedStage, $label, $fromTime, $toTime, $maxX, $minX, $maxY, $minY, $timeDiff);}
+    if (!$selectedStage) {$gnuplot->plotAllStagesTimeSeries($label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, \%gnuplotFiles);}
+    else {$gnuplot->plotSingleTimeSeries($gnuplotFiles{$selectedStage}, $selectedStage, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff);}
 
 }
@@ -107,5 +118,5 @@
 ###########################################################################
 sub plotHistogram {
-    my ($label, $fromTime, $toTime) = @_;
+    my ($label, $beginTime, $endTime) = @_;
 
     my ($tempFile, $filePath) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$save_temps);
@@ -114,5 +125,5 @@
     foreach $stage (@allStages) {
 
-        $czarDb->countProcessedPendingAndFaults($label, $stage, $fromTime, $toTime, \$processed, \$pending, \$faults);
+        $czarDb->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);
         print $tempFile "$stage $processed, $pending, $faults\n";
     }
@@ -120,5 +131,5 @@
     close($tempFile);
 
-    $gnuplot->plotHistogram($filePath, $label, $fromTime, $toTime);
+    $gnuplot->plotHistogram($filePath, $label, $beginTime, $endTime);
 }
 
