home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / rollfwd.prg < prev    next >
Text File  |  1993-10-14  |  2KB  |  92 lines

  1. /*
  2.  * File......: ROLLFWD.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_ROLLFWD()
  24.  *  $CATEGORY$
  25.  *      Date
  26.  *  $ONELINER$
  27.  *      Roll a date forward
  28.  *  $SYNTAX$
  29.  *      GT_RollFwd( dDate )
  30.  *  $ARGUMENTS$
  31.  *      dDate - Date to roll forward
  32.  *  $RETURNS$
  33.  *      The rolled date
  34.  *  $DESCRIPTION$
  35.  *      Roll the given date forward to the next available week day
  36.  *  $EXAMPLES$
  37.  *
  38.  *  $SEEALSO$
  39.  *
  40.  *  $INCLUDE$
  41.  *
  42.  *  $END$
  43.  */
  44. *
  45. FUNCTION GT_RollFwd( dDate )
  46.  
  47. /*****************************************************************************
  48.  Purpose - Roll the given date forward to a week day
  49.  Returns - Next available week day
  50.  Author  - Martin Colloby
  51.  Created - 11/9/90
  52. ******************************************************************************
  53.  Parameters - dDate  - Date to consider
  54.  Locals     - dDate1 - Nearest business date
  55.  Privates   - None
  56.  Externals  - None
  57. *****************************************************************************/
  58.  
  59. * For now we are not concerned with bank holidays.
  60.  
  61. LOCAL dDate1
  62.  
  63. IF VALTYPE( dDate ) <> "D"
  64.     GT_Warning( "Invalid date type passed to GT_RollFwd !" )
  65.     RETURN NIL
  66. ENDIF
  67.  
  68. DO CASE
  69.     CASE DOW( dDate ) == 1
  70.         * Sunday
  71.         dDate1 := dDate + 1
  72.  
  73.     CASE DOW( dDate ) == 7
  74.         * Saturday
  75.         dDate1 := dDate + 2
  76.  
  77.     OTHERWISE
  78.         * Weekday
  79.         dDate1 := dDate
  80.  
  81. ENDCASE
  82.  
  83. * If the rolled-to date is in a different month to the start date, then we
  84. * must roll back into the correct month.
  85. IF MONTH( dDate1 ) != MONTH( dDate )
  86.     dDate1 := dDate1 - 2
  87. ENDIF
  88.  
  89. * Return the calculated date
  90. RETURN( dDate1 )
  91. *
  92.