Projects Personal Contact Rss
 


System Utilities / RadiusReport

Source Text

#!/usr/local/bin/perl
# Small perl program to check POSIX mktime() in your perl installation.
# Paul Gregg , March 1999.
# http://www.pgregg.com/projects/radiusreport/

use POSIX;

$ENV{'TZ'}="GMT";
tzset();

$RECORD_DATE_FMT = "DAY MON MDAY HH:MM:SS YEAR";

$recdate = "Mon Feb  9 22:59:13 1998";
$recdate =~ s/ +/ /g;
$recdate =~ s/:/ /g;
my @recdates = split(/ /, $recdate);
my $stdfmt = $RECORD_DATE_FMT;
$stdfmt =~ s/:/ /g;
my @stds = split(/ /, $stdfmt);
while ($foo = shift (@stds)) {
  $val = shift(@recdates);
  $$foo = $val;
}
$Timestamp = calendar_time( $DAY, $MON, $MDAY, $HH, $MM, $SS, $YEAR );
if ($Timestamp eq 884386753) {
  print "$recdate -> $Timestamp (GMT)\n";
  print "Successful, POSIX mktime() is available and working.\n";
} else {
  if ($Timestamp eq 0) {
    print "$recdate -> $Timestamp\nFailed.\n";
  } else {
    print "$recdate -> $Timestamp ($ENV{'TZ'})\n";
    print "ERROR: POSIX mktime() is exists but is returning wrong results.\n";
  }
}

sub calendar_time {
  my $day = shift;
  my $month = shift;
  my $mday = shift;
  my $hour = shift;
  my $min = shift;
  my $sec = shift;
  my $year = shift;
  $year -= 1900 if ($year >= 1900);
  my $cal = mktime($sec, $min, $hour,  $mday, $monthshash{$month}, $year,
                $weekhash{$day}, 0, 0);
  return $cal;
}



All content © Paul Gregg, 1994 - 2024
Page last updated: 15 July 2008 23:06:51.
This site https://pgregg.com has been online since 5th October 2000
Previous websites live at various URLs since 1994