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

  1. /*
  2.     File......: GT_TextDate.prg
  3.     Author....: Martin Bryant
  4.     BBS.......: The Dark Knight Returns
  5.     Net/Node..: 050/069
  6.     User Name.: Martin Bryant
  7.     Date......: 04/02/93
  8.     Revision..: 1.0
  9.  
  10.     This is an original work by Martin Bryant and is placed
  11.     in the public domain.
  12.  
  13.     Modification history:
  14.     ---------------------
  15.  
  16.     Rev 1.0 04/02/93
  17.     PD Revision.
  18. */
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *      GT_TEXTDATE()
  23.  *  $CATEGORY$
  24.  *      Date
  25.  *  $ONELINER$
  26.  *      Return a text string of a date
  27.  *  $SYNTAX$
  28.  *      GT_TextDate([<dDate>]) => cLongDate
  29.  *  $ARGUMENTS$
  30.  *      <dDate> is the date to be used.
  31.  *  $RETURNS$
  32.  *      "WeekDay the NNth of Month, Year" as a string
  33.  *  $DESCRIPTION$
  34.  *      To return a text string giving the date in long
  35.  *      hand for the date passed as the parameter.
  36.  *  $EXAMPLES$
  37.  *      cLongDate := GT_TextDate(DATE())
  38.  *
  39.  *      // "Thursday the 4th of February 1993"
  40.  *  $SEEALSO$
  41.  *
  42.  *  $INCLUDE$
  43.  *
  44.  *  $END$
  45.  */
  46.  
  47. #include "GT_LIB.ch"
  48.  
  49. FUNCTION GT_TextDate(dDate)
  50.  
  51. LOCAL cLongDate := ''
  52. LOCAL nDay := 0
  53.  
  54. Default dDate to DATE()
  55.  
  56. // First bit
  57. nDay := DAY(dDate)
  58. cLongDate := CDOW(dDate) + ' the ' + LTRIM(STR(nDay))
  59.  
  60. // St, nd, rd or th
  61. DO CASE
  62.     CASE nDay = 1 .OR. nDay = 21 .OR. nDay = 31
  63.         // st
  64.         cLongDate += 'st'
  65.  
  66.     CASE nDay = 2 .OR. nDay = 22
  67.         // nd
  68.         cLongDate += 'nd'
  69.  
  70.     CASE nDay = 3 .OR. nDay = 23
  71.         // rd
  72.         cLongDate += 'rd'
  73.  
  74.     OTHERWISE
  75.         // th
  76.         cLongDate += 'th'
  77.  
  78. ENDCASE
  79.  
  80. //  And the rest
  81. cLongDate += ' of ' + CMONTH(dDate) + ' ' + ;
  82.     STR(YEAR(dDate),4)
  83.  
  84. /*
  85.     End of GT_TextDate()
  86. */
  87. RETURN(cLongDate)
  88.  
  89.