EXTENSIVE user file and route cleanup, see Changes
[spider.git] / perl / DXUtil.pm
index 6d115a7b6273540810e42bdb8ea6c1728951c153..51272d743420eea029be9a8d0b9e04bc77e029a1 100644 (file)
@@ -29,6 +29,7 @@ require Exporter;
                         is_qra is_freq is_digits is_pctext is_pcflag insertitem deleteitem
                         is_prefix dd is_ipaddr $pi $d2r $r2d localdata localdata_mv
                         diffms _diffms _diffus difft parraydifft is_ztime basecall
+                        normalise_call
             );
 
 
@@ -564,8 +565,11 @@ sub difft
                }
        }
        return '-(ve)' if $t < 0;
-       my ($d,$h,$m,$s);
+       my ($y,$d,$h,$m,$s);
        my $out = '';
+       $y = int $t / (86400*365);
+       $out .= sprintf ("%s${y}y", $adds?' ':'') if $y;
+       $t -= $y * 86400 * 365;
        $d = int $t / 86400;
        $out .= sprintf ("%s${d}d", $adds?' ':'') if $d;
        $t -= $d * 86400;
@@ -598,6 +602,15 @@ sub parraydifft
 
 sub basecall
 {
-       my ($r) = $_[0] =~ m|^(?:[\w\d]+/)?([\w\d]+).*$|;
+       my ($r) = $_[0] =~ m{^((?:[\w\d]+/)?[\w\d]+(?:/[\w\d]+)*)(?:-\d+)?(?:-\#)?$};
        return $r;
 }
+
+sub normalise_call
+{
+       my ($c, $ssid) = $_[0] =~ m|^((?:[\w\d]+/)?[\d\w]+(?:/[\w\d]+)*)(?:-(\d+))?(?:-\#)?$|;
+       my $ncall = $c;
+       $ssid += 0;
+       $ncall .= "-$ssid" if $ssid;
+       return $ncall;
+}