# SccsId[] = "%W% (USL function) %G%"
              LY_name="LEAP_YEAR"
              if [ ".${SECONDS}" = "." ]; then # Bourne function already loaded?
                 [ ."`set|egrep '^$LY_name\(\)\{$'`" != . ] && LY_loaded=1
              else # Korn or Bash shell and function already loaded?
                 if [ `expr "\`uname -s\`" : "[Ll][Ii][Nn][Uu][Xx]"` -eq 0 ]; then
                    [ ."`typeset +f|awk '/^'$LY_name'[=\(]?/'`" != . ] && LY_loaded=1
                 else # Linux
                    [ ."`typeset -F|awk '/^'$LY_name'[=\(]?/'`" != . ] && LY_loaded=1
                 fi
              fi
              if [ 0${LY_loaded} -eq 0 ]; then
              #----------------------------------------------------------------------#
              LEAP_YEAR() # Function documentation located at bottom.                #
              #----------------------------------------------------------------------#
              { [ ."${AWK}" = . ] && { { [ -x /usr/bin/nawk ] && AWK=/usr/bin/nawk; } \
                                  ||   { [ -x /bin/gawk     ] && AWK=/bin/gawk    ; } \
                                  ||   { [ -x /usr/bin/awk  ] && AWK=/usr/bin/awk ; }; }

                if [ $# -gt 0 ]; then
                   $AWK -v yyyy=$1 \
                     'BEGIN {if (yyyy !~ /[0-9][0-9][0-9][0-9]/) exit 0;
                        exit (((yyyy%4==0 && yyyy%100!=0) || (yyyy%400==0)) ? 1 : 0)}'
                   return $?
                fi

                #------------------------------------------------------------#
                # Reaching here means something is amiss.                    #
                #------------------------------------------------------------#
                if [ .${SHLIB} = . ]; then SHLIB=/usr/local/scripts; export SHLIB; fi

                . $SHLIB/email_msg.sh # Calls $SHLIB/exit.sh

                #------------------------------------------------------------#
                # If the following variables are not set, use these defaults.#
                #------------------------------------------------------------#
                : ${script_name:=`basename $0`}
                : ${sp:="                    "}

                LY_ID="$script_name($LY_name)"

                EMAIL_MSG "ERROR: (Function) $LY_ID" \
                  "${sp}Insufficient args."          \
                  "${sp}Usage: $LY_name yyyy"
                return 2
              } # "LY_" prefix identifies this function's local variables.
              fi

              #======================================================================#
              #                       D O C U M E N T A T I O N                      #
              #======================================================================#
              #                                                                      #
              #      Author: Bob Orlando                                             #
              #                                                                      #
              #        Date: December 14, 1996                                       #
              #                                                                      #
              #  Program ID: leap_year.sh                                            #
              #                                                                      #
              #       Usage: LEAP_YEAR yyyy                                          #
              #                                                                      #
              #     Purpose: Determine if the given year is leap year or no.         #
              #                                                                      #
              #     Globals: No global variables are assigned in this function.      #
              #              "LY_" prefix identifies local function variables.       #
              #                                                                      #
              # Exit_status: Function error (e.g. user supplies invalid arguments)   #
              #              return 2.  Otherwise returns true or false (1 or 0)     #
              #              -- leap year or no.                                     #
              #                                                                      #
              #       Calls: $AWK, EMAIL_MSG, and EXIT library functions.            #
              #                                                                      #
              #       Notes: .....................................................   #
              #              .....................................................   #
              #                                                                      #
              #    Modified: 2004-04-02 Bob Orlando                                  #
              #                 v1.8  * Expand $AWK testing and assignment.          #
              #                                                                      #
              #              2004-03-03 Bob Orlando                                  #
              #                 v1.7  * Change set|egrep|awk to just set|egrep.      #
              #                                                                      #
              #----------------------------------------------------------------------#
            
Artificial Intelligence is no match for natural stupidity.
©Copyright Bob Orlando, 1996-2011
All rights reserved.
http://www.OrlandoKuntao.com
E-mail: Bob@OrlandoKuntao.com
Last update: Jan. 26, 2011
by Bob Orlando