Index: branches/czw_branch/20101203/tools/czarplot.pl
===================================================================
--- branches/czw_branch/20101203/tools/czarplot.pl	(revision 30118)
+++ branches/czw_branch/20101203/tools/czarplot.pl	(revision 30586)
@@ -7,10 +7,8 @@
 use POSIX qw/strftime/;
 
-use czartool::CzarDb;
-use czartool::Gpc1Db;
+use czartool::Config;
 use czartool::Plotter;
 use czartool::StageMetrics;
 
-my $czarDbName = "czardb";
 my $label = undef;
 my $stage = undef;
@@ -36,5 +34,4 @@
 
 GetOptions (
-        "dbname=s" => \$czarDbName,
         "label|l=s" => \$label,
         "stage|s=s" => \$stage,
@@ -114,4 +111,6 @@
 if ($quit) { exit; }
 
+my $config = new czartool::Config();
+
 # default values
 if (!$rate && !$magicMask && !$nebulous && !$histogram && !$analysis && !$timeSeries) {$timeSeries = 1;}
@@ -121,39 +120,33 @@
 else {$savingToFile = 1;}
 
-my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser");
-my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose, $save_temps);
-$czarDb->setDateFormat("%Y%m%d-%H%i%s");
+my $czarDb = $config->getCzarDbInstance();
 
+my $newDayTime =  $config->getMetricsStartTime();
 
 my $plotter = undef; 
 if ($savingToFile) {
 
-    $plotter = czartool::Plotter->new_file(
-            $gpc1Db,
-            $czarDb,
-            $path,
-            $save_temps);
+    $plotter = czartool::Plotter->new_file($config, $path, $save_temps);
 }
 else {
 
-    $plotter = czartool::Plotter->new_display(
-            $gpc1Db, 
-            $czarDb, 
-            $save_temps);
+    $plotter = czartool::Plotter->new_display($config, $save_temps);
 }
 
-# sort out times
+# if a single day has been chosen 
 if($day) {
 
     if ($magicMask) {
 
-        $begin =  $day;
+        $begin = $day;
         $end = $day;
     }
     else {
 
-        # day plots should run from about 6:30am until midnight
-        $begin = "$day 06:35";
-        $end = "$day 23:59";
+        # plots should span 24 housr from previous day
+        my $dayBefore = $czarDb->subtractInterval($day, "1 DAY");
+                
+        $begin = "$dayBefore $newDayTime";
+        $end = "$day $newDayTime";
     }
 }
@@ -163,8 +156,14 @@
     if (!$begin) {
 
+        my $today = strftime('%Y-%m-%d', localtime);
+        my $yesterday = $czarDb->subtractInterval($today, "1 DAY");
+
+        
         if ($timeinpast) {$begin = $czarDb->subtractInterval($end, $timeinpast);}
-        else {$begin =  strftime('%Y-%m-%d 06:35',localtime);}
+        elsif ($czarDb->isBefore($end, "$today $newDayTime")) {$begin = "$yesterday $newDayTime";}
+        else {$begin = "$today $newDayTime";}
     }
 }
+
 if ($rate) {
 
