home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_PRNTIM.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  1.1 KB  |  35 lines

  1. *****************************************************************
  2. FUNCTION PRNTTIME (intime)
  3. *****************************************************************
  4.  
  5. * Converts a 24-hour time string to hh:mm AM or hh:mm PM format
  6.  
  7. * Copyright(c) 1991 -- James Occhiogrosso
  8.  
  9. LOCAL outtime := ''
  10.  
  11. * If time string not passed or wrong type, default to system time
  12. IF VALTYPE(intime) != 'C' .OR. EMPTY(intime)
  13.    intime = TIME()
  14. ENDIF
  15.  
  16. * Check first two characters (hours value) of time string
  17. IF VAL(intime) > 12 .AND. VAL (intime) < 24
  18.    * If hours more than 12, subtract 12 and set to PM
  19.    outtime = STR(VAL(intime) - 12, 2) + ;
  20.              SUBSTR(intime, 3, 3) + ' PM'
  21.  
  22. ELSEIF VAL(intime) < 12
  23.    * If hours is below 12, test for midnight and set to AM
  24.    outtime = IF(LEFT(intime, 2) = '00', '12' + SUBSTR(intime,  ;
  25.              3, 3), IF(LEFT(intime, 1) = '0', + ' ' +          ;
  26.              SUBSTR(intime, 2,4), SUBSTR(intime, 1, 5))) + ' AM'
  27.  
  28. ELSEIF VAL(intime) = 12
  29.    * If hours is 12 (noon), set to PM
  30.    outtime = SUBSTR(intime, 1, 5) + ' PM'
  31.  
  32. ENDIF
  33.  
  34. RETURN outtime
  35.