Article Listing 1 Listing 2 Listing 3 Listing 4
Listing 5 Listing 6 Listing 7 Listing 8 Listing 9 jun2006.tar

Listing 3 day_of_week

?# Algorithm from Mike Keith's website:
# http://users.aol.com/s6sj7gt/mikecal.htm
# 0=Sun, 1=Mon, ... 6=Sat
# Seems to work for Y > -7

function day_of_week {

    integer Y=$1
    integer M=$2
    integer D=$3

    if (( $M < 3 ))
    then
        Z=$(($Y-1))
    else
        Z=$Y
    fi

    if (( $M >= 3 ))
    then
        C=2
    else
        C=0
    fi

    echo $(( ((23*M)/9+D+4+Y+(Z/4)-(Z/100)+(Z/400)-C)%7 ))
}
# End Listing 3: