fix new pc9x midnight rollover bug
[spider.git] / perl / test_lastid.pl
diff --git a/perl/test_lastid.pl b/perl/test_lastid.pl
new file mode 100755 (executable)
index 0000000..1bd0ea3
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+
+my $pc9x_past_age = 3600;
+my $pc9x_future_age = 3600*2;
+my $lastid;
+
+try($_) for qw(85955 85968 518 85967 519 85968 520 85969), @ARGV;
+
+exit 0;
+
+sub try
+{
+       my $t = shift;
+
+       print "$t : ";
+
+       if (defined $lastid) {
+               if ($t < $lastid) {
+                       my $wt;
+                       if (($wt = $t+86400-$lastid) > $pc9x_past_age) {
+                               print "PCPROT: dup id on $t + 86400 - $lastid ($wt) > $pc9x_past_age, ignored\n";
+                               return;
+                       }
+                       print "wt = $wt ";
+               } elsif ($t == $lastid) {
+                       print "PCPROT: dup id on $t == $lastid, ignored\n";
+                       return;
+               } elsif ($t > $lastid) {
+                       if ($t - $lastid > $pc9x_future_age) {
+                               print "PCPROT: dup id $t too far in future on $lastid\n";
+                               return;
+                       }
+               }
+       }
+
+       print "$lastid Ok\n";
+       $lastid = $t;
+}
+
+