Changeset 467 for trunk


Ignore:
Timestamp:
1999-08-24T09:21:38+12:00 (25 years ago)
Author:
sjboddie
Message:

small change to format_date

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/sorttools.pm

    r392 r467  
    3636
    3737# takes arguments of day, month, year and converts to
    38 # date of form yyyymmdd. month may be full (e.g. "January")
    39 # or abbreviated (e.g. "Jan"). Years like "86" will be
    40 # assumed to be "1986".
     38# date of form yyyymmdd. month may be full (e.g. "January"),
     39# abbreviated (e.g. "Jan"), or a number (1-12). Years like "86"
     40# will be assumed to be "1986".
    4141sub format_date {
    4242    my ($day, $month, $year) = @_;
     
    6161    $day = "0$day" if (length($day) == 1);
    6262
    63     if (!defined $months{$month}) {
     63    if ($month =~ /^\d\d?$/) {
     64    if ($month < 1) {
     65        print STDERR "sorttools::format_date WARNING month $month out of range\n";
     66        $month = "01";
     67    } elsif ($month > 12) {
     68        print STDERR "sorttools::format_date WARNING month $month out of range\n";
     69        $month = "12";
     70    }
     71    if ($month =~ /^\d$/) {
     72        $month = "0" . $month;
     73    }
     74    } elsif (!defined $months{$month}) {
    6475    print STDERR "sorttools::format_date WARNING month $month out of range\n";
    6576    $month = "01";
Note: See TracChangeset for help on using the changeset viewer.