home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CLIBSRC2.ZIP / GETDATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.3 KB  |  82 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - getdate.c
  3.  *
  4.  * function(s)
  5.  *        getdate - gets MS-DOS date
  6.  *        gettime - gets MS-DOS time
  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 <dos.h>
  19.  
  20. /*---------------------------------------------------------------------*
  21.  
  22. Name            getdate - gets MS-DOS date
  23.  
  24. Usage           #include <dos.h>
  25.                 void getdate(struct date *dateblk);
  26.  
  27. Prototype in    dos.h
  28.  
  29. Description     getdate fills in the date structure (pointed to by
  30.                 dateblk) with the system's current date.
  31.  
  32.                 The date structure is defined as follows:
  33.  
  34.                 struct date {
  35.                         int da_year;    (* Current year *)
  36.                         char da_day;    (* Day of the month *)
  37.                         char da_mon;    (* Month (1 = Jan) *)
  38.                 };
  39.  
  40. Return value    nothing
  41.  
  42. *---------------------------------------------------------------------*/
  43. void _CType getdate(struct date *datep)
  44. {
  45.         _AH = 0x2a;
  46.         geninterrupt(0x21);
  47.         ((int *)datep)[0] = _CX;
  48.         ((int *)datep)[1] = _DX;
  49. }
  50.  
  51. /*---------------------------------------------------------------------*
  52.  
  53. Name            gettime - gets MS-DOS time
  54.  
  55. Usage           #include <dos.h>
  56.                 void gettime(struct time *timep);
  57.  
  58. Prototype in    dos.h
  59.  
  60. Description     gettime fills in the time structure pointed to by timep
  61.                 with the system's current time.
  62.  
  63.                 The time structure is defined as follows:
  64.  
  65.                 struct time {
  66.                         unsigned char ti_min;   (* Minutes *)
  67.                         unsigned char ti_hour;  (* Hours *)
  68.                         unsigned char ti_hund;  (* Hundredths of seconds *)
  69.                         unsigned char ti_sec;   (* Seconds *)
  70.                 };
  71.  
  72. Return value    nothing
  73.  
  74. *---------------------------------------------------------------------*/
  75. void _CType gettime(struct time *timep)
  76. {
  77.         _AH = 0x2c;
  78.         geninterrupt(0x21);
  79.         ((int *)timep)[0] = _CX;
  80.         ((int *)timep)[1] = _DX;
  81. }
  82.