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

Listing 9 ordinal_date

function ordinal_date
{
    set -A DAYS_TO_MONTH NA 0 31 59 90 120 151 181 212 243 273 304 334 365

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

    integer N=$(($D+${DAYS_TO_MONTH[$M]}))

    if is_leap_year $Y
    then
        if (( $M > 2 ))
        then
            N=$((N+1))
        fi
    fi

    echo $N
}
# End Listing 9: