package CALENDAR;
# intialize month lookup
{
    my $month;
    %months = map { $_ => ++$month }
      @months = qw(jan feb mar apr may jun jul aug sep oct nov dec);
}

sub month2num { # month
    my $month = shift;
    return $month if ($month > 0 && $month < 13);
    $month =~ s/^(...).*$/\L$1/;
    return $months{$month} if ($months{$month});
    return 0;
}
# takes random formats (call getdate.pm?) and gives yyyymmdd.
sub parsedate {
    my $input = shift;
    local($y,$m,$d);
    if($input =~ /^\d+\.\d+\.\d+$/) {
	($y,$m,$d) = split(/\./,$input);
	return sprintf("%04d%02d%02d",$y,$m,$d);
    } elsif ($input =~ /^\d{8}$/) {
	return $input;
    }
}

1;
