home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / DEMOS / UT_TEST2.C < prev   
Encoding:
C/C++ Source or Header  |  1990-07-24  |  2.6 KB  |  84 lines

  1. /*********************
  2.  *
  3.  *  ut_test2.c - utilities test program.
  4.  *
  5.  *  Purpose: This file contains tests of the utility functions.
  6.  *           See also ut_test1.c
  7.  *
  8.  *  Blackstar C Function Library
  9.  *  (c) Copyright 1985 Sterling Castle Software
  10.  *
  11.  *******/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include "blackstr.h"
  16. #include "ut_head.h"
  17. #include "co_head.h"
  18.  
  19. void main()
  20. {
  21.     int          i;
  22.     char         timestr[64],datestr[128];
  23.     struct DATE  adate;
  24.     extern int   hour_,minute_,sec_,hsec_;
  25.     extern char  timeoptf_,dateoptf_;
  26.     long         ldate,ltime;
  27.     char         *ptr;
  28.     extern char  *ut_todaystr();
  29.  
  30.     co_init(0);
  31.     co_mode(BW80,FWHITE,BBLACK);
  32.     co_clr();               /* clear screen */
  33.  
  34.     kb_init(NULL,NULL,NULL);
  35.     printf("Hello from utilities test 2");
  36.  
  37.     printf("\n\n\rPhase 1 - Pause for 2 secs");
  38.     ut_gtime();
  39.     printf("\n\rTime at start is %02d:%02d:%02d.%02d", hour_,minute_,sec_,hsec_);
  40.     ut_pause(200);
  41.     ut_gtime();
  42.     printf("\n\rTime at end   is %02d:%02d:%02d.%02d", hour_,minute_,sec_,hsec_);
  43.  
  44.     printf("\n\n\rPhase 2 - Convert long integer date & time (and global hr & min) to strings");
  45.     ldate = ut_datel();
  46.     ut_ldatestr(datestr,ldate);
  47.     printf("\n\rLong integer date is %8ld", ldate);
  48.     printf("\n\rDate in a string is  %s", datestr);
  49.     ltime = ut_timel();
  50.     ut_ldates(&adate,ldate);
  51.     printf("\n\rDate in structure from ut_ldates is %02d/%02d/%d",
  52.         adate.mo, adate.dy, adate.yr);
  53.     dateoptf_|=DYR2F;
  54.     ut_ldates(&adate,ldate);
  55.     printf("\n\rDate in structure from ut_ldates with 2 digit YR is %02d/%02d/%d",
  56.         adate.mo, adate.dy, adate.yr);
  57.     ut_ltimestr(timestr,ltime);
  58.     printf("\n\rLong integer time is %8ld", ltime);
  59.     printf("\n\rTime in a string is  %s", timestr);
  60.     timeoptf_|=TSECF;
  61.     ut_ltimestr(timestr,ltime);
  62.     printf("\n\rLong integer time is %8ld", ltime);
  63.     printf("\n\rTime in a string with seconds is  %s", timestr);
  64.     ut_gtime();
  65.     timeoptf_=0;
  66.     ut_hmtimestr(timestr,hour_,minute_);
  67.     printf("\n\rHours & minutes are  %02d:%02d", hour_, minute_);
  68.     printf("\n\rHr & min in a string %s", timestr);
  69.  
  70.     printf("\n\n\rPress <CR> to continue with next phase");
  71.     kb_getc();
  72.  
  73.     ut_gtod();
  74.     printf("\n\n\rPhase 3 - Get day of week integer & name, month name, etc");
  75.     i = ut_today();
  76.     printf("\n\rToday's day of week integer is %d  (Sunday = 0)", i);
  77.     ptr = ut_todaystr();
  78.     printf("\n\rToday's day of week name is %s", ptr);
  79.  
  80.     printf("\n\nEND OF TEST - Press any key to exit...");
  81.     kb_getc();
  82.     co_clr();               /* clear screen */
  83. }
  84.