home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / pine4.10.tar.gz / pine4.10.tar / pine4.10 / pico / blddate.c < prev    next >
C/C++ Source or Header  |  1996-03-15  |  2KB  |  57 lines

  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. /*
  5.  * Pine and Pico are registered trademarks of the University of Washington.
  6.  * No commercial use of these trademarks may be made without prior written
  7.  * permission of the University of Washington.
  8.  * 
  9.  * Pine, Pico, and Pilot software and its included text are Copyright
  10.  * 1989-1996 by the University of Washington.
  11.  * 
  12.  * The full text of our legal notices is contained in the file called
  13.  * CPYRIGHT, included with this distribution.
  14.  */
  15.  
  16. main(argc, argv)
  17.     int    argc;
  18.     char **argv;
  19. {
  20.     struct tm *t;
  21.     FILE      *outfile=stdout;
  22.     time_t     ltime;
  23. #ifdef OS2
  24.     char       hostname[256];
  25.  
  26.     gethostname(hostname, sizeof hostname - 1);
  27. #endif
  28.  
  29.     if(argc > 1 && (outfile = fopen(argv[1], "w")) == NULL){
  30.     fprintf(stderr, "can't create '%s'\n", argv[1]);
  31.     exit(1);
  32.     }
  33.  
  34.     time(<ime);
  35.     t = localtime(<ime);
  36.     fprintf(outfile,"char datestamp[]=\"%02d-%s-%d\";\n", t->tm_mday, 
  37.         (t->tm_mon == 0) ? "Jan" : 
  38.          (t->tm_mon == 1) ? "Feb" : 
  39.           (t->tm_mon == 2) ? "Mar" : 
  40.            (t->tm_mon == 3) ? "Apr" : 
  41.         (t->tm_mon == 4) ? "May" : 
  42.          (t->tm_mon == 5) ? "Jun" : 
  43.           (t->tm_mon == 6) ? "Jul" : 
  44.            (t->tm_mon == 7) ? "Aug" : 
  45.             (t->tm_mon == 8) ? "Sep" : 
  46.              (t->tm_mon == 9) ? "Oct" : 
  47.               (t->tm_mon == 10) ? "Nov" : 
  48.                (t->tm_mon == 11) ? "Dec" : "UKN",
  49.         1900 + t->tm_year);
  50. #ifdef OS2
  51.     fprintf(outfile, "char hoststamp[]=\"%s\";\n", hostname);
  52. #else
  53.     fprintf(outfile, "char hoststamp[]=\"random-pc\";\n");
  54. #endif
  55.     exit(0);
  56. }
  57.