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

  1. /*
  2.  * File......: DAYSMONT.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_DAYSINMONTH()
  24.  *  $CATEGORY$
  25.  *      Date
  26.  *  $ONELINER$
  27.  *      Return the number of days in a month
  28.  *  $SYNTAX$
  29.  *      GT_DaysInMonth( dDate )
  30.  *  $ARGUMENTS$
  31.  *      dDate - Date to be considered
  32.  *  $RETURNS$
  33.  *      Number of days in given month
  34.  *  $DESCRIPTION$
  35.  *      Returns the number of days in a month
  36.  *  $EXAMPLES$
  37.  *      Find the last day in February 1993 :
  38.  *
  39.  *          nDay := GT_DaysInMonth( CTOD( "01/02/93" ) )
  40.  *  $SEEALSO$
  41.  *
  42.  *  $INCLUDE$
  43.  *
  44.  *  $END$
  45.  */
  46.  
  47. *
  48. FUNCTION GT_DaysInMonth( dDate )
  49.  
  50. /*****************************************************************************
  51.  Purpose - Return number of days in month
  52.  Returns - None
  53.  Author  - Martin Colloby
  54.  Created - 27/06/91
  55. ******************************************************************************
  56.  Parameters - p_date      - Date to consider
  57.  Privates   - None
  58.  Locals     - None
  59.  Externals  - None
  60. *****************************************************************************/
  61.  
  62. LOCAL nDays  := 0
  63. LOCAL nMonth := 0
  64. LOCAL lLeap  := .F.
  65.  
  66. IF VALTYPE( dDate ) != "D"
  67.     GT_Warning( "Invalid date type passed to GT_DaysInMonth ! ")
  68.     RETURN NIL
  69. ENDIF
  70.  
  71. nMonth := MONTH( dDate )
  72.  
  73. lLeap := GT_LeapYear( dDate )
  74.  
  75. DO CASE
  76.     CASE nMonth == 2 .AND. lLeap  ; nDays := 29
  77.     CASE nMonth == 2 .AND. !lLeap ; nDays := 28
  78.     CASE nMonth == 4  ; nDays := 30
  79.     CASE nMonth == 6  ; nDays := 30
  80.     CASE nMonth == 9  ; nDays := 30
  81.     CASE nMonth == 11 ; nDays := 30
  82.     OTHERWISE         ; nDays := 31
  83. ENDCASE
  84.  
  85. RETURN( nDays )
  86. *
  87.