home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / CLIBS / TIME / TEST / TIMTST.C < prev   
Encoding:
C/C++ Source or Header  |  1996-07-08  |  1.2 KB  |  59 lines

  1. #include <stdarg.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "..\stdinc\time.h"
  5.  
  6. _LL_GETTIME(struct tm *tm2)
  7. {
  8.     time_t t = time(0);
  9.     *tm2 = *localtime(&t);
  10. }
  11. _LL_TICKS()
  12. {
  13.     return 0;
  14. }
  15. time_t MKTIME(struct tm *a);
  16. struct tm* GMTIME(time_t *t);
  17. struct tm* LOCALTIME(time_t *t);
  18. char *ASCTIME(struct tm *t);
  19. char *CTIME(time_t *t);
  20.  
  21. void query(char *string, int *val)
  22. {
  23.     char istring[100];
  24.     printf("\n%s? ",string);
  25.     gets(istring);
  26.     *val = atoi(istring);
  27. }
  28. void main(void)
  29. {
  30.     time_t t,t1;
  31.     struct tm a,b,c;
  32.     char buf[100],buf2[100];
  33.     printf("%d\n",0x7fffffff/86400/365+70);
  34.     while (1) {
  35.         query("sec",&a.tm_sec);
  36.         query("min",&a.tm_min);
  37.         query("hr",&a.tm_hour);
  38.         query("month",&a.tm_mon);
  39.         query("day",&a.tm_mday);
  40.         query("year",&a.tm_year);
  41.         t = MKTIME(&a);
  42.         t1 = mktime(&a);
  43.         printf("MKTIME: %d %d\n",t,t1);
  44.         t1 = TIME(0);
  45.         strcpy(buf,CTIME(&t));
  46.         strcpy(buf2,CTIME(&t1));
  47.         printf("CTIME: %s %s\n",buf,buf2);
  48.         b = *GMTIME(&t);
  49.         c = *gmtime(&t);
  50.         strcpy(buf,ASCTIME(&b));
  51.         strcpy(buf2,ASCTIME(&c));
  52.         printf("GMTIME: %s %s",buf,buf2);
  53.         b = *LOCALTIME(&t);
  54.         c = *localtime(&t);
  55.         strcpy(buf,ASCTIME(&b));
  56.         strcpy(buf2,ASCTIME(&c));
  57.         printf("LOTIME: %s %s",buf,buf2);
  58.     }
  59. }