home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / YEAR.PRG < prev   
Text File  |  1992-09-28  |  3KB  |  99 lines

  1. /*
  2.  * File......: YEAR.PRG
  3.  * Author....: Jo W. French dba Practical Computing
  4.  * CIS_ID....: 74731,1751
  5.  * Date......: $Date:   28 Sep 1992 00:45:50  $
  6.  * Revision..: $Revision:   1.3  $
  7.  * Log file..: $Logfile:   C:/nanfor/src/year.prv  $
  8.  * 
  9.  * The functions contained herein are the original work of Jo W. French
  10.  * and are placed in the public domain.
  11.  *
  12.  * Modification history:
  13.  * ---------------------
  14.  *
  15.  * $Log:   C:/nanfor/src/year.prv  $
  16.  * 
  17.  *    Rev 1.3   28 Sep 1992 00:45:50   GLENN
  18.  * Jo French cleaned up.
  19.  * 
  20.  *    Rev 1.2   15 Aug 1991 23:04:56   GLENN
  21.  * Forest Belt proofread/edited/cleaned up doc
  22.  * 
  23.  *    Rev 1.1   14 Jun 1991 19:53:20   GLENN
  24.  * Minor edit to file header
  25.  * 
  26.  *    Rev 1.0   01 Apr 1991 01:02:36   GLENN
  27.  * Nanforum Toolkit
  28.  *
  29.  */
  30.  
  31. /*  $DOC$
  32.  *  $FUNCNAME$
  33.  *     FT_YEAR()
  34.  *  $CATEGORY$
  35.  *     Date/Time
  36.  *  $ONELINER$
  37.  *     Return calendar or fiscal year data
  38.  *  $SYNTAX$
  39.  *     FT_YEAR( [ <dGivenDate> ] ) -> aDateInfo
  40.  *  $ARGUMENTS$
  41.  *     <dGivenDate> is any valid date in any date format.  Defaults
  42.  *     to current system date if not supplied.
  43.  *  $RETURNS$
  44.  *     A three element array containing the following data:
  45.  *
  46.  *        aDateInfo[1] - The year as a character string "YYYY"
  47.  *        aDateInfo[2] - The beginning date of the year
  48.  *        aDateInfo[3] - The ending date of the year
  49.  *  $DESCRIPTION$
  50.  *     FT_YEAR() returns an array containing data about the year
  51.  *     containing the given date.
  52.  *
  53.  *     Normally the return data will be based on a year beginning
  54.  *     on January 1st.
  55.  *
  56.  *     The beginning of year date can be changed by using FT_DATECNFG(),
  57.  *     which will affect all subsequent calls to FT_YEAR() until another
  58.  *     call to FT_DATECNFG().
  59.  *
  60.  *     The beginning of year date may be reset to January 1 by calling
  61.  *     FT_DATECNFG() with no parameters.
  62.  *  $EXAMPLES$
  63.  *     // Get info about year containing 9/15/90, assuming default
  64.  *     // beginning of year is January 1st.
  65.  *     aDateInfo := FT_YEAR( Ctod("09/15/90") )
  66.  *     ? aDateInfo[1]   //  1990
  67.  *     ? aDateInfo[2]   //  01/01/90     beginning of year
  68.  *     ? aDateInfo[3]   //  12/31/90     end of year
  69.  *
  70.  *     // get info about current year (1991).
  71.  *     aDateInfo := FT_YEAR()
  72.  *     ? aDateInfo[1]   //  1991
  73.  *     ? aDateInfo[2]   //  01/01/91   beginning of year
  74.  *     ? aDateInfo[3]   //  12/31/91   end of year
  75.  *  $SEEALSO$
  76.  *     FT_DATECNFG() FT_WEEK() FT_MONTH() FT_QTR()
  77.  *  $END$
  78. */
  79.  
  80. FUNCTION FT_YEAR(dGivenDate)
  81.  
  82.   LOCAL aRetVal[3], cFY_Start, cDateFormat
  83.  
  84.   cFY_Start   := FT_DATECNFG()[1]
  85.   cDateFormat := SET(_SET_DATEFORMAT, "yyyy.mm.dd")
  86.   IF( VALTYPE(dGivenDate) != 'D', dGivenDate := DATE(), )
  87.  
  88.   aRetVal[2]  := CTOD(STR( YEAR(dGivenDate) - IF(MONTH(dGivenDate) < ;
  89.                     MONTH(CTOD(cFY_Start)), 1, 0), 4) + ;
  90.                     SUBSTR(cFY_Start, 5, 6) )
  91.   aRetval[3]  := FT_MADD(aRetVal[2], 12) - 1
  92.   aRetVal[1]  := STR(YEAR(aRetVal[3]),4)      // End of Year
  93.  
  94.   SET(_SET_DATEFORMAT, cDateFormat)
  95.  
  96. RETURN aRetVal
  97.  
  98.  
  99.