PATH=/bin:/usr/bin if test $# -ne 3 then echo usage: zeller year month day >&2 exit 1 fi # Zeller algorithm part one: adjust so that March is month zero newmonth=`expr $2 - 3` # -1 to convert to zero-origin, then -2 for zeller algo newyear=$1 if test $newmonth -lt 0 then newyear=`expr $newyear - 1` newmonth=`expr $newmonth + 12` fi # Zeller algorithm part two: the big formula weekday=`echo \ 26 $newmonth 1 + \* 2 - 10 / \ $3 + \ $newyear 100 % + \ $newyear 100 % 4 / + \ $newyear 400 / + \ 2 $newyear 100 / \* - \ 7777 + \ 7 % p | dc` # turn that into a day name day0=Sunday day1=Monday day2=Tuesday day3=Wednesday day4=Thursday day5=Friday day6=Saturday eval echo \$day$weekday