home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / GetTimeDateString.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-10  |  750 b   |  29 lines  |  [TEXT/MMCC]

  1. /*
  2. GetTimeDateString
  3.  
  4. Return a malloced string with the time and date in a nice format:
  5.     "5:03 PM, Monday, September 13, 1993"
  6. You may supply a calendar time, as returned by time(), or you may supply 0 to
  7. use the current time. 
  8.  
  9. HISTORY:
  10. 8/93    dhb,jms    wrote it, using Apple toolbox.
  11. 9/13/93    dgp    rewrote it using Standard C library.
  12. 9/16/93 dhb Fixed name of routine in PrintfExit.
  13. 7/16/94 dgp suppress leading zero in hours.
  14. */
  15. #include "VideoToolbox.h"
  16. #include <time.h>    /* Standard C library */
  17.  
  18. char *GetTimeDateString(time_t t)
  19. {
  20.     char *s;
  21.     
  22.     s=malloc(64);
  23.     if(s==NULL)PrintfExit("GetTimeDateString: malloc(64) failed.\n");
  24.     if(t==0)t=time(NULL);
  25.     strftime(s,64,"%I:%M %p, %A, %B %d, %Y",localtime(&t));
  26.     if(s[0]=='0')strcpy(s,s+1);
  27.     return(s);
  28. }
  29.