X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXUtil.pm;h=3ce684988537bbfa5632790d2afb929b38c6240e;hb=f46017e7bef9ee062cd5a8648d214eabe585da25;hp=d7ddcf6263f28d7a2065b5da5cc192e654de0854;hpb=2e16209416d1d189707935868a708b525c93097b;p=spider.git diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index d7ddcf62..3ce68498 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -1,23 +1,49 @@ # # various utilities which are exported globally # +# Copyright (c) 1998 - Dirk Koopman G1TLH +# +# $Id$ +# package DXUtil; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(atime +@EXPORT = qw(atime ztime cldate ); @month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); +# a full time for logging and other purposes sub atime { - my ($sec,$min,$hour,$mday,$mon,$year) = gmtime(time); + my $t = shift; + my ($sec,$min,$hour,$mday,$mon,$year) = gmtime((defined $t) ? $t : time); $year += 1900; my $buf = sprintf "%02d%s%04d\@%02d:%02d:%02d", $mday, $month[$mon], $year, $hour, $min, $sec; return $buf; } +# get a zulu time in cluster format (2300Z) +sub ztime +{ + my $t = shift; + my ($sec,$min,$hour) = gmtime((defined $t) ? $t : time); + $year += 1900; + my $buf = sprintf "%02d%02dZ", $hour, $min; + return $buf; + +} + +# get a cluster format date (23-Jun-1998) +sub cldate +{ + my $t = shift; + my ($sec,$min,$hour,$mday,$mon,$year) = gmtime((defined $t) ? $t : time); + $year += 1900; + my $buf = sprintf "%02d-%s-%04d", $mday, $month[$mon], $year; + return $buf; +}