home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Science⁄Math / VideoToolbox / VideoToolboxSources / GetTimeDateString.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  678 b   |  27 lines  |  [TEXT/KAHL]

  1. /*
  2. GetTimeDateString
  3.  
  4. Return a malloced string with the time and date in a nice format:
  5.     "10:43 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. */
  14. #include <VideoToolbox.h>
  15. #include <time.h>    /* Standard C library */
  16.  
  17. char *GetTimeDateString(time_t t)
  18. {
  19.     char *s;
  20.     
  21.     s=malloc(64);
  22.     if(s==NULL)PrintfExit("GetTimeDateString: malloc(64) failed.\n");
  23.     if(t==0)t=time(NULL);
  24.     strftime(s,64,"%I:%M %p, %A, %B %d, %Y",localtime(&t));
  25.     return(s);
  26. }
  27.