#!/bin/sh

id=$1
year=$2
per=$3

case $year in
  1995) ndfeb=08;twoorthree=2;;
  1996) ndfeb=09;twoorthree=3;;
  1997) ndfeb=08;twoorthree=2;;
  1998) ndfeb=08;twoorthree=2;;
  1999) ndfeb=08;twoorthree=2;;
  2000) ndfeb=09;twoorthree=3;;
  2001) ndfeb=08;twoorthree=2;;
  2002) ndfeb=08;twoorthree=2;;
  2003) ndfeb=08;twoorthree=2;;
  2004) ndfeb=09;twoorthree=3;;
  2005) ndfeb=08;twoorthree=2;;
  2006) ndfeb=08;twoorthree=2;;
  2007) ndfeb=08;twoorthree=2;;
  2008) ndfeb=09;twoorthree=3;;
  2009) ndfeb=08;twoorthree=2;;
  2010) ndfeb=08;twoorthree=2;;
  *)    ndfeb=08;twoorthree=2; echo "*** SELECTED YEAR OUT OF 1995-2010:";
                               echo "FEBRUARY MONTH LENGTH SET TO 28, PLS CHECK";;
esac

case ${per} in
  JAN1)   month=01;day=01;ndays=10;next=JAN2;;
  JAN2)   month=01;day=11;ndays=10;next=JAN3;;
  JAN3)   month=01;day=21;ndays=11;next=FEB1;;
  FEB0)   month=01;day=29;ndays=03;next=FEB1;;
  FEB1)   month=02;day=01;ndays=10;next=FEB2;;
  FEB2)   month=02;day=11;ndays=10;next=FEB3;;
  FEB3)   month=02;day=21;ndays=${ndfeb};next=MAR1;;
  MAR0)   month=02;day=27;ndays=${twoorthree};next=MAR1;;
  MAR1)   month=03;day=01;ndays=10;next=MAR2;;
  MAR2)   month=03;day=11;ndays=10;next=MAR3;;
  MAR3)   month=03;day=21;ndays=11;next=APR1;;
  APR0)   month=03;day=29;ndays=03;next=APR1;;
  APR1)   month=04;day=01;ndays=10;next=APR2;;
  APR2)   month=04;day=11;ndays=10;next=APR3;;
  APR3)   month=04;day=21;ndays=10;next=MAY1;;
  MAY0)   month=04;day=28;ndays=03;next=MAY1;;
  MAY1)   month=05;day=01;ndays=10;next=MAY2;;
  MAY2)   month=05;day=11;ndays=10;next=MAY3;;
  MAY3)   month=05;day=21;ndays=11;next=JUN1;;
  JUN0)   month=05;day=29;ndays=03;next=JUN1;;
  JUN1)   month=06;day=01;ndays=10;next=JUN2;;
  JUN2)   month=06;day=11;ndays=10;next=JUN3;;
  JUN3)   month=06;day=21;ndays=10;next=JUL1;;
  JUL0)   month=06;day=28;ndays=03;next=JUL1;;
  JUL1)   month=07;day=01;ndays=10;next=JUL2;;
  JUL2)   month=07;day=11;ndays=10;next=JUL3;;
  JUL3)   month=07;day=21;ndays=11;next=AUG1;;
  AUG0)   month=07;day=29;ndays=03;next=AUG1;;
  AUG1)   month=08;day=01;ndays=10;next=AUG2;;
  AUG2)   month=08;day=11;ndays=10;next=AUG3;;
  AUG3)   month=08;day=21;ndays=11;next=SEP1;;
  SEP0)   month=08;day=29;ndays=03;next=SEP1;;
  SEP1)   month=09;day=01;ndays=10;next=SEP2;;
  SEP2)   month=09;day=11;ndays=10;next=SEP3;;
  SEP3)   month=09;day=21;ndays=10;next=OCT1;;
  OCT1)   month=10;day=01;ndays=10;next=OCT2;;
  OCT2)   month=10;day=11;ndays=10;next=OCT3;;
  OCT3)   month=10;day=21;ndays=11;next=NOV1;;
  NOV1)   month=11;day=01;ndays=10;next=NOV2;;
  NOV2)   month=11;day=11;ndays=10;next=NOV3;;
  NOV3)   month=11;day=21;ndays=10;next=DEC1;;
  DEC1)   month=12;day=01;ndays=10;next=DEC2;;
  DEC2)   month=12;day=11;ndays=10;next=DEC3;;
  DEC3)   month=12;day=21;ndays=11;next=YEND;;
esac
nhours=`echo ${ndays} | gawk '{print $1*24}'`

case $id in
  MONTH)  echo $month ;;
  DAY)    echo $day   ;;
  NHOURS) echo $nhours;;
  NEXT)   echo $next  ;;
esac
