Index: main/trunk/greenstone2/perllib/oaiinfo.pm
===================================================================
--- main/trunk/greenstone2/perllib/oaiinfo.pm	(revision 31210)
+++ main/trunk/greenstone2/perllib/oaiinfo.pm	(revision 31216)
@@ -4,4 +4,5 @@
 use constant INFO_STATUS_INDEX  => 0;
 use constant INFO_TIMESTAMP_INDEX => 1;
+use constant INFO_DATESTAMP_INDEX => 2;
 
 use strict;
@@ -10,14 +11,14 @@
 use dbutil;
 
-# QUESTIONS:
-# Should we use time or localtime(time) for timestamp? Just timestamp.
-# What format should the timestamp be in, or is the basic format used by perl sufficient? Basic.
-
-# File format read in: OID <tab> Date-timestamp <tab> Deletion-Status
+# Store timestamp in 2 formats: internal and external (same as oailastmodified and oailastmodifieddate)
+# These times indicate the last modified date for that document. In the case of the doc being deleted,
+# it's the time the doc was deleted.
+
+# File format read in: OID <tab> (Deletion-)Status <tab> Timestamp <tab> Datestamp
 
 # Deletion status can be:
 #  E = Doc with OID exists (has not been deleted from collection). Timestamp indicates last time of build
 #  D = Doc with OID has been deleted. Timestamp indicates time of deletion
-#  PD = Provisionally Deleted. Timestamp momentarily unaltered.
+#  PD = Provisionally Deleted. The associated timestamps are momentarily unaltered.
 
 # oaidb is "always incremental": always reflects the I/B/R/D status of archive info db,
@@ -30,5 +31,5 @@
  
     my $self = { 
-	'info'=>{} # map of {OID, array[deletion-status,timestamp]} pairs
+	'info'=>{} # map of {OID, array[deletion-status,timestamp,datestamp]} pairs
     };
     
@@ -343,4 +344,5 @@
 	print STDERR " status: " . $self->{'info'}->{$OID}->[INFO_STATUS_INDEX];
 	print STDERR " time: " . $self->{'info'}->{$OID}->[INFO_TIMESTAMP_INDEX];
+	print STDERR " date: " . $self->{'info'}->{$OID}->[INFO_DATESTAMP_INDEX];
 	print STDERR "\n";
     }
@@ -401,5 +403,5 @@
     # the following method will set to current time if no timestamp provided,
     # But by explicit here, the code is easier to follow
-    $self->set_info($OID, "D", $self->get_current_time()); 
+    $self->set_info($OID, "D", $self->get_current_time());
 
 }
@@ -413,4 +415,16 @@
     # return localtime; # same as localtime(time); # http://perldoc.perl.org/functions/localtime.html
     
+}
+
+sub get_datestamp {
+    my $self = shift (@_);
+    my ($timestamp) = @_;
+
+    my ($seconds, $minutes, $hours, $day_of_month, $month, $year,
+	    $wday, $yday, $isdst) = localtime($timestamp);
+
+    my $datestamp = sprintf("%d%02d%02d",1900+$year,$month+1,$day_of_month);
+
+    return $datestamp;
 }
 
@@ -452,6 +466,7 @@
 	my ($deletion_status) = ($vals=~/^<status>(.*)$/m);
 	my ($timestamp) = ($vals=~/^<timestamp>(.*)$/m);
-	
-	$self->set_info ($oid, $deletion_status, $timestamp);
+	my ($datestamp) = ($vals=~/^<datestamp>(.*)$/m);
+	
+	$self->add_info ($oid, $deletion_status, $timestamp, $datestamp);
     }
 }
@@ -509,5 +524,7 @@
     foreach my $oid ( keys $self->{'info'} ) {
 	my $OID_info = $self->{'info'}->{$oid};
-	my $val = "<status>".$OID_info->[INFO_STATUS_INDEX]."\n<timestamp>".$OID_info->[INFO_TIMESTAMP_INDEX]."\n";
+	my $val = "<status>".$OID_info->[INFO_STATUS_INDEX];
+	$val .= "\n<timestamp>".$OID_info->[INFO_TIMESTAMP_INDEX];
+	$val .= "\n<datestamp>".$OID_info->[INFO_DATESTAMP_INDEX]."\n";
 	&dbutil::write_infodb_rawentry($infodbtype,$infodb_handle,$oid,$val);
     }
@@ -535,13 +552,23 @@
     my $self = shift (@_);
     my ($OID, $del_status, $timestamp) = @_;
+
     if(!defined $timestamp) { # get current date timestamp
 	$timestamp = $self->get_current_time();
     }
-    $self->{'info'}->{$OID} = [$del_status, $timestamp];
-
-}
-
-
-# returns a list of the form [[OID, timestamp, deletion_status], ...]
+    my $datestamp = $self->get_datestamp($timestamp);
+
+    $self->{'info'}->{$OID} = [$del_status, $timestamp, $datestamp];
+
+}
+
+sub add_info { # called to load a single record from file into memory, so it should be provided all 4 fields
+    my $self = shift (@_);
+    my ($OID, $del_status, $timestamp, $datestamp) = @_;
+
+    $self->{'info'}->{$OID} = [$del_status, $timestamp, $datestamp];
+}
+
+
+# returns a list of the form [[OID, deletion_status, timestamp, datestamp], ...]
 sub get_OID_list 
 {
@@ -554,5 +581,7 @@
 
 	push (@list, [$OID, $OID_info->[INFO_STATUS_INDEX], 
-		      $OID_info->[INFO_TIMESTAMP_INDEX]]);
+		      $OID_info->[INFO_TIMESTAMP_INDEX],
+		      $OID_info->[INFO_DATESTAMP_INDEX]
+	      ]);
     }
 
