home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOPAS
/
TP-LA1.LBR
/
DATEDIT.IQC
/
DATEDIT.INC
Wrap
Text File
|
2000-06-30
|
3KB
|
73 lines
{DATEDIT.INC}
PROCEDURE Date_Edit (DE_Date : String8; Var Result : Integer);
{This procedure will verify a date passed as a string in
MM/DD/YY form and return a result of:
0, when date is O.K. 4, when YY is invalid
1, when MM is invalid 5, when MM and YY are invalid
2, when DD is invalid 6, when DD and YY are invalid
3, when MM and DD are invalid 7, when all fields are invalid
Author : L. L. Smith; 2827 Klusner Ave.; Parma, OH 44134
Application: CP/M-80, CP/M-86, MS-DOS, PC-DOS}
var
DE : string[2];
DE_Month, DE_Day, DE_Year : integer;
Begin
If Length(DE_Date) < 8 then
DE_Date := '00000000';
DE := Copy(DE_Date,1,2);
Val(DE, DE_Month, Result);
If Result <> 0 then
DE_Month := 0;
DE := Copy(DE_Date,4,2);
Val(DE, DE_Day, Result);
If Result <> 0 then
DE_Day := 0;
DE := Copy(DE_Date,7,2);
Val(DE, DE_Year, Result);
If Result <> 0 then
DE_Year := -1;
If DE_Month In [1..12] then
Result := 0
Else
Result := 1;
If DE_Day In [1..31] then
Result := Result
Else
Result := Result + 2;
If DE_Year < 0 then
Result := Result + 4
Else
If DE_Year > 99 then
Result := Result + 4;
If Result = 0 then
If DE_Day In [29,30,31] then
Case DE_Day of
29 : If DE_Month = 2 then
Begin
Result := DE_Year Mod 4;
If Result <> 0 then
Result := 2
Else
If DE_Year = 0 then
Result := 2;
end; (* of Begin *)
30 : If DE_Month = 2 then
Result := 2;
31 : If DE_Month In [2,4,6,9,11] then
Result := 2;
end; (* of Case *)
Case Result of
0 : Result := 0;
1 : Error_Msg('MONTH','DATE',Line_Number + 2);
2 : Error_Msg('DAY','DATE',Line_Number + 2);
3 : Error_Msg('MONTH and DAY','DATE',Line_Number + 2);
4 : Error_Msg('YEAR','DATE',Line_Number + 2);
5 : Error_Msg('MONTH and YEAR','DATE',Line_Number + 2);
6 : Error_Msg('DAY and YEAR','DATE',Line_Number + 2);
7 : Error_Msg('DATE','DATE',Line_Number + 2);
end; (* Case *)
End; (* Date_Edit *)