home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_01 / 8n01032a < prev    next >
Text File  |  1990-02-19  |  1KB  |  44 lines

  1.  
  2.  
  3. Listing 4
  4.  
  5. #define MAXDATEPRINTS 10
  6. 
  7.  
  8. date_print2(date)
  9. date date;      /* internal date form */
  10. {
  11.         static struct datecache {
  12.                 date internal;
  13.                 printable_date external;
  14.         } dates[MAXDATEPRINTS];
  15.  
  16.         static struct datecache *d_last_used = dates;
  17. #define next_date(x) ((x==&dates[MAXDATEPRINTS-1])?dates:x+1)
  18.  
  19.         /* last one used is highly likely */
  20.         struct datecache *d = d_last_used;
  21.  
  22.         do {
  23.                 if (d->internal == date) {
  24.                         d_last_used = d;
  25.                         return(d->external);
  26.                 }
  27.                 d = next_date(d);
  28.         } while (d != d_last_used);
  29. 
  30.  
  31.         /* we have moved all the way around the buffer */
  32.         /* and didn't find it in cache */
  33.         /* get next buffer */
  34.         d_last_used = next_date(d);
  35.  
  36.         /* actually do the work and convert date */
  37.         /* into a printable representation */
  38.         .....
  39.         memcpy(d_last_used->external,....);
  40.         return(d_last_used->external);
  41. }
  42.  
  43.  
  44.