#!/bin/ksh # days into year daysin() { integer monthin=0 if [[ $2 -eq 2 ]] ; then monthin=31 fi if [[ $2 -eq 3 ]] ; then monthin=59 fi if [[ $2 -eq 4 ]] ; then monthin=90 fi if [[ $2 -eq 5 ]] ; then monthin=120 fi if [[ $2 -eq 6 ]] ; then monthin=151 fi if [[ $2 -eq 7 ]] ; then monthin=181 fi if [[ $2 -eq 8 ]] ; then monthin=212 fi if [[ $2 -eq 9 ]] ; then monthin=243 fi if [[ $2 -eq 10 ]] ; then monthin=273 fi if [[ $2 -eq 11 ]] ; then monthin=304 fi if [[ $2 -eq 12 ]] ; then monthin=334 fi # much better ways to do the above - see later integer leap=$3%4 if [[ leap -eq 0 && $2 -gt 2 ]] ; then monthin=$monthin+1 fi let days=$1+$monthin return } #---------------------------------------------------------------- # d=`date +%d` m=`date +%m` y=`date +%y` daysin $d $m $y print days into year = $days