home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
MADTRB21.ZIP
/
GETDATE.SRC
< prev
next >
Wrap
Text File
|
1985-10-26
|
3KB
|
69 lines
{->>>>GetDate<<<<----------------------------------------------}
{ }
{ Filename: GETDATE.SRC -- Last Modified 10/25/85 }
{ }
{ This routine returns the current system date through DOS }
{ call $2A. It requires a prior definition of types DateRec }
{ and String80. DateString is formatted this way: }
{ }
{ Wednesday, July 17, 1986 }
{ }
{ DateRec = RECORD }
{ DateComp : Integer; }
{ DateString : String80; }
{ Year,Month,Day : Integer; }
{ DayOfWeek : Integer }
{ END; }
{ }
{ DayOfWeek is a code from 0-6, with 0 = Sunday. }
{ DateComp is an integer generated by the formula: }
{ DateComp = (Year-1980)*512 + (Month*64) + Day }
{ It is used for comparing two dates to determine which is }
{ earlier. }
{--------------------------------------------------------------}
PROCEDURE GetDate(VAR Today : DateRec);
TYPE
String9 = String[9];
Reg = RECORD
CASE Boolean OF
False : (Word : Integer);
True : (LoByte,HiByte : Byte)
END;
Regpack = RECORD
AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Reg
END;
CONST
MonthTags : ARRAY [1..12] of String9 =
('January','February','March','April','May','June','July',
'August','September','October','November','December');
DayTags : ARRAY [0..6] OF String9 =
('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
VAR
Regs : RegPack;
Temp1 : String80;
BEGIN
Regs.AX.HiByte := $2A; MSDOS(Regs);
WITH Today DO
BEGIN
Year := Regs.CX.Word;
Month := Regs.DX.HiByte;
Day := Regs.DX.LoByte;
DayOfWeek := Regs.AX.LoByte;
DateString := DayTags[DayOfWeek] + ', ';
Str(Day,Temp1);
DateString := DateString +
MonthTags[Month] + ' ' + Temp1 + ', ';
Str(Year,Temp1);
DateString := DateString + Temp1;
DateComp := (Year - 1980) * 512 + (Month * 64) + Day
END
END;