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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - dosgdate.c
  3.  *
  4.  * function(s)
  5.  *        _dos_getdate - gets MS-DOS date (MSC compatible)
  6.  *        _dos_gettime - gets MS-DOS time (MSC compatible)
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1991, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #define _MSC
  19. #include <dos.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            _dos_getdate - gets MS-DOS date
  24.  
  25. Usage           #include <dos.h>
  26.                 void _dos_getdate(struct dosdate_t *dateblk);
  27.  
  28. Prototype in    dos.h
  29.  
  30. Description     _dos_getdate fills in the dosdate_t structure (pointed to by
  31.                 dateblk) with the system's current date.
  32.  
  33.                 The dosdate_t structure is defined as follows:
  34.  
  35.                 struct dosdate_t {
  36.                         unsigned char day;      (* 1-31 *)
  37.                         unsigned char month;    (* 1-12 *)
  38.                         unsigned int  year;     (* 1980 - 2099 *)
  39.                         unsigned char dayofweek;(* 0 - 6 (0=Sunday) *)
  40.                 };
  41.  
  42. Return value    nothing
  43.  
  44. Note            Compatible with Microsoft C.  Not the same as getdate().
  45.  
  46. *---------------------------------------------------------------------*/
  47. void _dos_getdate(struct dosdate_t *datep)
  48. {
  49.         _AH = 0x2a;
  50.         geninterrupt(0x21);
  51.         datep->dayofweek = _AL;
  52.         datep->day = _DL;
  53.         datep->month = _DH;
  54.         datep->year = _CX;
  55. }
  56.  
  57.  
  58. /*---------------------------------------------------------------------*
  59.  
  60. Name            _dos_gettime - gets MS-DOS time
  61.  
  62. Usage           #include <dos.h>
  63.                 void _dos_gettime(struct dostime_t *timep);
  64.  
  65. Prototype in    dos.h
  66.  
  67. Description     _dos_gettime fills in the dostime_t structure pointed to
  68.                 by timep with the system's current time.
  69.  
  70.                 The dostime_t structure is defined as follows:
  71.  
  72.                 struct dostime_t {
  73.                         unsigned char hour;     (* Hours *)
  74.                         unsigned char minute;   (* Minutes *)
  75.                         unsigned char second;   (* Seconds *)
  76.                         unsigned char hsecond;  (* Hundredths of seconds *)
  77.                 };
  78.  
  79. Return value    nothing
  80.  
  81. Note            Compatible with Microsoft C.  Not the same as gettime().
  82.  
  83. *---------------------------------------------------------------------*/
  84. void _dos_gettime(struct dostime_t *timep)
  85. {
  86.         _AH = 0x2c;
  87.         geninterrupt(0x21);
  88.         timep->hour = _CH;
  89.         timep->minute = _CL;
  90.         timep->second = _DH;
  91.         timep->hsecond = _DL;
  92. }
  93.