home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / contrib / ServiceMail / src / pdinq / getdate / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-15  |  676 b   |  36 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/timeb.h>
  4. #include <time.h>
  5. char *ctime();
  6. struct tm *localtime();
  7. char *timezone();
  8. time_t getdate();
  9. struct timeb now;
  10. main() {
  11.     time_t ret; char buf[300];
  12.     register char *p;
  13.     register struct tm *l;
  14.  
  15. #ifndef TNULL
  16.     ftime(&now);
  17. #endif
  18.     while(fgets(buf, 300, stdin) != NULL) {
  19.         buf[strlen(buf)-1] = '\0';
  20. #ifdef TNULL
  21.         ftime(&now);
  22.         ret = getdate(buf, (struct timeb *) NULL);
  23. #else
  24.         ret = getdate(buf, &now);
  25. #endif
  26.         if (ret >= 0) {
  27.             p = ctime(&ret);
  28.             p[strlen(p)-1] = '\0';
  29.             l = localtime(&ret);
  30.             printf("%D  %s %s\n", ret, p,
  31.                 timezone(now.timezone, l->tm_isdst));
  32.         }
  33.         else printf("%D\n", ret);
  34.     }
  35. }
  36.