Simple date issue

Hi all,

i have used the search already before someone shouts at me and i have seen the 'datecalc' program but this is not working correctly for me in the shell and environment i am using.

I am using solaris 10 and bourne shell.

I have two dates '07-04-2009' and '05-05-2009'. I just need to know when the number of days exceeds 90 between two dates.

i.e. 

num_days='07-04-2009' - '05-05-2009'

if [ $num_days -gt 90 ]; then
    do action....
fi

I can do it in Perl but this doesnt handle leap years etc:

epoch()
{
        perl -e '
                use Time::Local;

                $fmt = "%s";  # %s = seconds in epoch
                $mday = substr("$ARGV[0]", 6, 2);
                $mon =  substr("$ARGV[0]", 4 ,2);
                $year = substr("$ARGV[0]", 0 ,4);
                $time = timelocal(0,0,0,$mday,$mon,$year);
                print int $time;
                ' "$1"
}

date1=$( epoch '070709' );
date2=$( epoch '070809' );

diff=$(( $date1 - $date2 ))

if [[ $diff -gt 7776000 ] ; then
  do action....
fi

If you only want the time between two dates, no need to bug yourself with Time::Local if the original POSIX functions are good enough:

$ perl -MPOSIX -e 'print mktime(0,0,0,1,4-1,2008-1900),"\n";'
1207004400
$ perl -MPOSIX -e 'print mktime(0,0,0,1,1-1,2008-1900),"\n";'
1199142000
$ echo "(1207004400-1199142000)/86400" | bc -q -l
91.00000000000000000000
$ perl -MPOSIX -e 'print mktime(0,0,0,1,4-1,2009-1900),"\n";'
1238540400
$ perl -MPOSIX -e 'print mktime(0,0,0,1,1-1,2009-1900),"\n";'
1230764400
$ echo "(1238540400-1230764400)/86400" | bc -q -l
90.00000000000000000000

thanks pludi :b: