# SAVE THIS CODE AS cala_day.sh
#
# Uses Zellers Congruence calculation to use a date and give
# the day of the week that date was.
#
# This function expects 3 Arguments,
# DAY MONTH YEAR
# then
# Returns a value between 0 and 6 to represent the day of the
# week where 0=Sun,1=Mon,...6=Sat
#
# e.g cala_day.sh 25 12 2005
#
# This formula is Year 2000 compliant.
# It is not compliant using dates previous to Oct 1752
#
# Adjust Month such that March becomes 1 month of
# year and Jan/Feb become 11/12 of previous year
# =============================================
if [ $MONTH -ge 3 ] ; then
MONTH=`expr $MONTH - 2`
else
MONTH=`expr $MONTH + 10`
fi
if [ $MONTH -eq 11 ] || [ $MONTH -eq 12 ] ; then
YEAR=`expr $YEAR - 1`
fi
# ==============================================
# Split YEAR into YEAR and CENTURY
# ================================
CENTURY=`expr $YEAR / 100`
YEAR=`expr $YEAR % 100`
# ================================