package DXUtil;
+use Date::Parse;
+use Carp;
+
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(atime ztime cldate cldatetime slat slong yesno promptf parray parraypairs
- print_all_fields
+ print_all_fields cltounix
);
@month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
return "$date $time";
}
+# return a unix date from a cluster date and time
+sub cltounix
+{
+ my $date = shift;
+ my $time = shift;
+ $date =~ s/^\s*(\d+)-(\w\w\w)-(19\d\d)$/$1 $2 $3/;
+ $time =~ s/^(\d\d)(\d\d)Z$/$1:$2 +0000/;
+ return str2time("$date $time");
+}
+
# turn a latitude in degrees into a string
sub slat
{
$let = $n >= 0 ? 'N' : 'S';
$n = abs $n;
$deg = int $n;
- $min = int (($n - $deg) * 60);
+ $min = int ((($n - $deg) * 60) + 0.5);
return "$deg $min $let";
}
$let = $n >= 0 ? 'E' : 'W';
$n = abs $n;
$deg = int $n;
- $min = int (($n - $deg) * 60);
+ $min = int ((($n - $deg) * 60) + 0.5);
return "$deg $min $let";
}
# take an arg as an array list and print it
sub parray
{
- return join(', ', @{shift});
+ my $ref = shift;
+ return join(', ', @{$ref});
}
# take the arg as an array reference and print as a list of pairs