home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / STIME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.1 KB  |  82 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. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19.  
  20. #include <time.h>
  21. #include <dos.h>
  22.  
  23. /*---------------------------------------------------------------------*
  24.  
  25. Name            stime - sets time
  26.  
  27. Usage           int stime(long *tp);
  28.  
  29. Related
  30. functions usage    long time(long *tloc);
  31.  
  32. Prototype in    time.h
  33.  
  34. Description     see time
  35.  
  36. *---------------------------------------------------------------------*/
  37. int stime(time_t *tp)
  38. {
  39.     struct    date    d;
  40.     struct    time    t;
  41.  
  42.     unixtodos(*tp, &d, &t);
  43.     setdate(&d);
  44.     settime(&t);
  45.     return (0);
  46. }
  47.  
  48.  
  49. /*---------------------------------------------------------------------*
  50.  
  51. Name            time - gets time of day
  52.  
  53. Usage           long time(long *tloc);
  54.  
  55. Related
  56. functions usage    int stime(long *tp);
  57.  
  58. Prototype in    time.h
  59.  
  60. Description     time retrieves the current time (in seconds, elapsed
  61.         since 00:00:00 GMT, January 1, 1970) and stores that
  62.         value in the location pointed to by tloc.
  63.  
  64.         stime sets the system time and date.
  65.  
  66. Return value    time returns the elapsed time, stime returns 0.
  67.  
  68. *---------------------------------------------------------------------*/
  69. time_t time(time_t *tloc)
  70. {
  71.     struct    date    d;
  72.     struct    time    t;
  73.     time_t          x;
  74.  
  75.     getdate(&d);
  76.     gettime(&t);
  77.     x = dostounix(&d, &t);
  78.     if (tloc)
  79.         *tloc = x;
  80.     return (x);
  81. }
  82.