Index: trunk/ippTasks/register.pro
===================================================================
--- trunk/ippTasks/register.pro	(revision 30181)
+++ trunk/ippTasks/register.pro	(revision 30240)
@@ -102,4 +102,6 @@
 
 $valid_burntool_value = 14
+$sunrise = '17:30:00'
+$sunset  = '03:30:00'
 
 macro replace.survey.values
@@ -302,4 +304,5 @@
     # XXX register_imfile.pl differs from the standard script : it does not have an 'outroot' argument, and it does not take '--redirect'
     $run = register_imfile.pl --exp_id $EXP_ID --tmp_class_id $TMP_CLASS_ID --tmp_exp_name $TMP_EXP_NAME --uri $URI --logfile $logfile --bytes $BYTES --md5sum $MD5SUM
+    $run = $run --sunset $sunset --sunrise $sunrise
     add_standard_args run
 
@@ -544,9 +547,20 @@
   # select entried from the current DB; cycle to the next DB, if it exists
   task.exec
+     book npages nsData -var Npages
+     if ($Npages == 0) 
+       $today = `date -u +%Y-%m-%d`
+     else 
+       book getpage nsData $ns_datePAGE -var today
+       $ns_datePAGE ++
+       if ($ns_datePAGE >= $Npages) set ns_datePAGE = 0
+     end
+
     $run = regtool -pendingburntoolimfile
-    $today = `date -u +%Y-%m-%d`
+
 # debugging purposes
 #   $today = "2010-12-25"
-    $run = $run -date $today -valid_burntool $valid_burntool_value
+    $dateobs_begin = $today\T$sunset
+    $dateobs_end   = $today\T$sunrise
+    $run = $run -dateobs_begin $dateobs_begin -dateobs_end $dateobs_end -valid_burntool $valid_burntool_value
     if ($DB:n == 0)
       option DEFAULT
