home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / JDTPPROG.ZIP / GETDATE.SRC < prev    next >
Encoding:
Text File  |  1985-08-19  |  1.7 KB  |  50 lines

  1. {->>>>GetDate<<<<----------------------------------------------}
  2. { This routine returns the current system date through DOS     }
  3. { call $2A.  It requires a prior definition of types DateRec   }
  4. { and String80.  DateString is formatted this way:             }
  5. {                                                              }
  6. {     July 17, 1986                                            }
  7. {                                                              }
  8. {     DateRec = Record                                         }
  9. {                 DateString     : String80;                   }
  10. {                 Year,Month,Day : Integer                     }
  11. {               End;                                           }
  12. {--------------------------------------------------------------}
  13.  
  14. Procedure GetDate(Var Today : DateRec);
  15.  
  16.  
  17. Type Reg     = Record
  18.                  Case Boolean of
  19.                    True : (Word : Integer);
  20.                    False: (LoByte : Byte;
  21.                            HiByte : Byte)
  22.                End;
  23.  
  24.      RegPack = Record
  25.                  AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : Reg
  26.                End;
  27.  
  28.      String8 = String[8];
  29.  
  30. Const MonthTags : Array [1..12] of String8 =
  31.     ('January','February','March','April','May','June','July',
  32.      'August','September','October','November','December');
  33.  
  34. Var Regs  : RegPack;
  35.     Dummy : String80;
  36.  
  37. Begin
  38.   Regs.AX.HiByte := $2A; MSDOS(Regs);
  39.   With Today Do
  40.     Begin
  41.       Year := Regs.CX.Word;
  42.       Month := Regs.DX.HiByte;
  43.       Day := Regs.DX.LoByte;
  44.       Str(Day,Dummy);
  45.       DateString := MonthTags[Month] + ' ' + Dummy + ', ';
  46.       Str(Year,Dummy);
  47.       DateString := DateString + Dummy
  48.     End
  49. End;
  50.