OK, OK, I know it's been beaten to death, but I came up with a cool way to test for leap year in Korn Shell.
Basically it uses '[tt]cal[/tt]' to get a calendar of February of this year (simple mod to get other years), [tt]grep[/tt]s that one month calendar for a '29', then counts how many rows the grep output. If it's a leap year, IS_LEAP will equal 1. If it's not a leap year, IS_LEAP will be a 0. So IS_LEAP can be used as a boolean as in the example code.
Code:
#!/bin/ksh
typeset -i IS_LEAP=$( cal 2 $(date '+%Y') | grep 29 | wc -l )
(( IS_LEAP )) && print "This is a leap year!"
if (( ! IS_LEAP ))
then
print "NOT a leap year!"
fi
Basically it uses '[tt]cal[/tt]' to get a calendar of February of this year (simple mod to get other years), [tt]grep[/tt]s that one month calendar for a '29', then counts how many rows the grep output. If it's a leap year, IS_LEAP will equal 1. If it's not a leap year, IS_LEAP will be a 0. So IS_LEAP can be used as a boolean as in the example code.