home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / STIME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.8 KB  |  80 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - stime.c
  3.  *
  4.  * function(s)
  5.  *        stime - sets time of day
  6.  *        time  - gets time of day
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <time.h>
  19. #include <dos.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            stime - sets time
  24.  
  25. Usage           int stime(long *tp);
  26.  
  27. Related
  28. functions usage long time(long *tloc);
  29.  
  30. Prototype in    time.h
  31.  
  32. Description     see time
  33.  
  34. *---------------------------------------------------------------------*/
  35. int stime(time_t *tp)
  36. {
  37.         struct  date    d;
  38.         struct  time    t;
  39.  
  40.         unixtodos(*tp, &d, &t);
  41.         setdate(&d);
  42.         settime(&t);
  43.         return (0);
  44. }
  45.  
  46.  
  47. /*---------------------------------------------------------------------*
  48.  
  49. Name            time - gets time of day
  50.  
  51. Usage           long time(long *tloc);
  52.  
  53. Related
  54. functions usage int stime(long *tp);
  55.  
  56. Prototype in    time.h
  57.  
  58. Description     time retrieves the current time (in seconds, elapsed
  59.                 since 00:00:00 GMT, January 1, 1970) and stores that
  60.                 value in the location pointed to by tloc.
  61.  
  62.                 stime sets the system time and date.
  63.  
  64. Return value    time returns the elapsed time, stime returns 0.
  65.  
  66. *---------------------------------------------------------------------*/
  67. time_t time(time_t *tloc)
  68. {
  69.         struct  date    d;
  70.         struct  time    t;
  71.         time_t          x;
  72.  
  73.         getdate(&d);
  74.         gettime(&t);
  75.         x = dostounix(&d, &t);
  76.         if (tloc)
  77.                 *tloc = x;
  78.         return (x);
  79. }
  80.