validating dates

This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor.
I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... whats the best way to go that deep?
I'm working in digital unix ksh.
thanks!

while :; do
echo "Enter starting invoice date (CCYYMMDD or Quit): \c"
read DATE1
CENT1=`echo $DATE1 | cut -c1,2`
YR1=`echo $DATE1 | cut -c3,4`
MO1=`echo $DATE1 | cut -c5,6`
DD1=`echo $DATE1 | cut -c7,8`

case "$CENT1" in
19 | 20 ) ;;

  • ) echo "Invalid Century, please re-enter entire date. \n" ;;
    esac
    case "$MO1" in
    01|02|03|04|05|06|07|08|09|10|11|12 ) ;;
  • ) echo "Invalid Month, please re-enter entire date. \n" ;;
    esac

Take a look at my datecalc routine. You can use the -j option to validate a date.

datecalc -j 2000 2 29
returns a Modified Julian Day Number while
datecalc -j 2002 2 29
returns an error message. In either case the return code is set. The error message goes to stderr while the MJD goes to stdout.

datecalc is here.

WOW ! Looks great!

I did a search before I did my posting and I thought I searched on "date" but I don't believe that post came up. ???