Date functions: is_leap_year


is_leap_year() #@ Return successfully if YEAR (or current year) is a leap year
{              #@ USAGE: is_leap_year [YEAR]
    local year=$1 gregorian=1752
    [[ -z $year ]] && printf -v year '%(%Y)T'
    if (( year > gregorian ))
    then
      case $year in
        *0[48] |\
        *[2468][048] |\
        *[13579][26] |\
        *[02468][048]00 |\
        *[13579][26]00 ) return 0 ;;
        *) return 1
      esac
    else
      (( year % 4 == 0 ))
    fi
}