get_whatdays()
{
year=`echo $1|cut -c1-4`
month=`echo $1|cut -c5-6`
day=`echo $1|cut -c7-8`
{
#
Sample input:20020703
year=`echo $1|cut -c1-4`
month=`echo $1|cut -c5-6`
day=`echo $1|cut -c7-8`
b=`cal $month $year|wc -l `
dow=`cal $month $year |awk '{for(i=1;i<=NF;i++){if($i=='$day'){if (NR=='"$b"'-1){print i-1}else{print 7-NF+i-1}}}}'`
dow=`cal $month $year |awk '{for(i=1;i<=NF;i++){if($i=='$day'){if (NR=='"$b"'-1){print i-1}else{print 7-NF+i-1}}}}'`
# Convert the numeric day of the week to a string
case $dow in
0) print Sun ;;
1) print Mon ;;
2) print Tue ;;
3) print Wed ;;
4) print Thu ;;
5) print Fri ;;
6) print Sat ;;
*) print "wrong date" ;;
esac
}
case $dow in
0) print Sun ;;
1) print Mon ;;
2) print Tue ;;
3) print Wed ;;
4) print Thu ;;
5) print Fri ;;
6) print Sat ;;
*) print "wrong date" ;;
esac
}