Home About BC DR HA Support Training Download
You are here: Home/ Downloads/ Scripts/ Korn/ Functions/ Please Login or Register

-
Current Location
-

js
  Downloads
    Scripts
      Korn
        Functions
-
AIX Admin Methodology
Global Consolidation Project
All AIX admins should join
www.aixexpert.com


Join our LinkedIn Group
AIX Advanced Technical Experts
Contract Opportunities

www.LinkedIn.com

-
digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com

isLeap

Korn Shell 93 function to calculate leap year.



#!/usr/bin/ksh93
################################################################
####    Korn Shell function to determine whether or not a specified
####    4 digit year is a leap year.  This function is designed to
####    return the result as the return status of the function.
####    The isLeap function returns 0 if the year is a leap year,
####    and 1 if it is not a leap year.
####
####    Load this file into your current environment as follows:
####    
####    . ./isLeap
####    
####    Thats "dot-space-dot-slash-isLeap-dot-ksh"
####
####    You will then be able to issue the command "isLeap"
####    from your current environment.
####
####    SYNTAX: isLeap [-d] [-y ####]
####
####                   -d    print the number of days in february to STDOUT
####
####                   -y    Require a 4 digit year to be specified.  
####                         performs leap year test against specified year.
####
####    AUTHOR: Dana French
####    EMAIL: dfrench@xoommail.com
####
################################################################
isLeap()
{
  typeset TRUE="0"
  typeset FALSE="1"
  typeset STATUS="-1"
  typeset DFLAG="${FALSE}"
  typeset YFLAG="${FALSE}"
  typeset YEAR=`date +"%Y"`
  typeset OPTION

  while getopts ':dy:' OPTION
  do
    case ${OPTION} in
        'd') DFLAG="${TRUE}";;
        'y') YFLAG="${TRUE}"
             YEAR="${OPTARG}";;
        '?') print "
SYNTAX: isLeap [-d] [-y ####]

        -d    print the number of days in february to STDOUT

        -y    Require a 4 digit year to be specified.  
              performs leap year test against specified year.

"; return ${STATUS};;
    esac
  done

  if (( ${#YEAR} == 4 ))
  then
    STATUS="${FALSE}"
    ( ( (( ( YEAR % 4 )   == 0 )) &&
        (( ( YEAR % 100 ) != 0 )) ) ||
        (( ( YEAR % 400 ) == 0 )) ) &&
      STATUS="${TRUE}"

    (( DFLAG == TRUE )) && (( STATUS == TRUE )) && print "29"
    (( DFLAG == TRUE )) && (( STATUS == FALSE )) && print "28"
  else
    print "ERROR: Invalid year specified"
  fi
  return ${STATUS}
}

-
Is Leap Year
-
 


LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com