#!	/bin/csh -f
#
# Copyright 1993, 1994, 1995 by the Regents of the University of California.
# see the file "Copyright" in the distribution for conditions of use.
#
#
#	access UNIX "cal" command
#
retry:
echo -n "Enter either a month and year or just a year: "
set x = $<
set y = ( $x )
if( $#y == 0 ) exit
if( $#y > 2 ) then
	echo "Invalid input."
	goto retry
endif
echo ' '
#
set awkf = `mktemp`
cat << "EOT" > $awkf
BEGIN { mo["jan"] = 1; mo["feb"] = 2; mo["mar"] = 3; mo["apr"] = 4;
	mo["may"] = 5; mo["jun"] = 6; mo["jul"] = 7; mo["aug"] = 8;
	mo["sep"] = 9; mo["oct"] = 10; mo["nov"] = 11; mo["dec"] = 12;
}
{
	if( NF == 1 ) {
		month = " ";
		year = $1;
		if( year > 0 && year < 100 ) year += 1900;
	} else if( NF == 2 ) {
		year = $2;
		if( year > 0 && year < 100 ) year += 1900;
		month = $1;
		if( mo[substr(month,1,3)] != "" ) month = mo[substr(month,1,3)] ;
	}
	print month, year;
}
"EOT"
set z = `echo $x | tr A-Z a-z  | awk -f $awkf`
cal $z
/bin/rm $awkf
