Index: /tags/ipp-20100823/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
===================================================================
--- /tags/ipp-20100823/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 29333)
+++ /tags/ipp-20100823/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 29334)
@@ -100,5 +100,5 @@
         my $x = $row->{CENTER_X};
         my $y = $row->{CENTER_Y};
-        my $results = lookup_bycoord($ipprc, $rowList, $imagedb, $img_type, $tess_id, $component, $need_magic, $x, $y, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
+        my $results = lookup_bycoord($ipprc, $rowList, $imagedb, $img_type, $tess_id, $component, $need_magic, $x, $y, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose);
         return $results;
     }
@@ -164,5 +164,5 @@
 
     my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $img_type, $id, $tess_id, $component,
-        $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
+        $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose);
 
     return $results;
@@ -187,4 +187,6 @@
     my $data_group = shift;
     my $option_mask = shift;
+    my $mjd_min = shift;
+    my $mjd_max = shift;
     my $verbose  = shift;
 
@@ -348,4 +350,7 @@
         $command .= " -dateobs_begin $dateobs_begin" if $dateobs_begin;
         $command .= " -dateobs_end $dateobs_end" if $dateobs_end;
+    } else {
+        $command .= " -mjd_obs_begin $mjd_min" if $mjd_min;
+        $command .= " -mjd_obs_end $mjd_max" if $mjd_max;
     }
 
@@ -635,4 +640,6 @@
     my $data_group = shift;
     my $option_mask = shift;
+    my $mjd_min = shift;
+    my $mjd_max = shift;
     my $verbose    = shift;
 
@@ -650,5 +657,5 @@
                 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $img_type, $chip->{id},
                     $tess_id, $chip->{component}, $need_magic, 
-                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
+                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose);
 
                 next if !$these_results;
@@ -670,5 +677,5 @@
                 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $img_type, undef,
                     $skycell->{tess_id}, $skycell->{component}, $need_magic, 
-                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
+                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose);
 
                 next if !$these_results;
@@ -1006,4 +1013,12 @@
 
     my $ticks = ($mjd - 40587.0) * 86400;
+
+    # CONVERT from TAI to UTC
+    # XXX: do this correctly
+    if ($mjd >= 54832) {
+        $ticks += -34;
+    } else {
+        $ticks += -33;
+    }
 
     my ($sec, $min, $hr, $day, $mon, $year) = gmtime($ticks);
