#! /bin/sh usage () { echo "usage: $0 <year> <month> <day> [<cent>]" echo " exp. : 2007/3/31 is \"$0 7 3 31\"" exit 1 } [ $# -lt 3 ] && usage [ -z $4 ] && H=20 || H=$4 Y=$1 M=$2 D=$3 YEAR=`expr $H \* 100` YEAR=`expr $YEAR + $Y` DATE=${YEAR}/${M}/${D} echo DATE=$DATE if [ $M -le 2 ] ; then Y=`expr $Y - 1` M=`expr $M + 12` fi echo 'W = y + [ y / 4 ] + [ h / 4 ] - 2h + [ 13 ( m + 1) / 5 ] + d' tmp1=`expr $Y / 4` #echo tmp1=$tmp1 tmp2=`expr $H / 4` #echo tmp2=$tmp2 tmp3=`expr $H \* 2` #echo tmp3=$tmp3 tmp4=`expr $M + 1` tmp4=`expr $tmp4 \* 13` tmp4=`expr $tmp4 / 5` #echo tmp4=$tmp4 echo "W = $Y + $tmp1 + $tmp2 - $tmp3 + $tmp4 + $D" W=`expr $Y + $tmp1 + $tmp2 - $tmp3 + $tmp4 + $D` echo W=$W echo "R = W % 7" R=`expr $W % 7` echo R=$R echo -n "$DATE is " case $R in 0) echo "Saturday." ;; 1) echo "Sunday." ;; 2) echo "Monday." ;; 3) echo "Tuesday." ;; 4) echo "Wednesday." ;; 5) echo "Thirsday." ;; 6) echo "Friday." ;; *) echo "Unknown." ;; esac echo OK exit 0