home *** CD-ROM | disk | FTP | other *** search
- {$A+,B+,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}
- {$M 65520,0,655360}
- Program DateDemo;
-
- Uses CRT,TPDB,TPDBDate;
-
- {Demonstration of date handling functions.}
-
- {Field Field Name Type Width Dec
- 1 DATE1 Date 8
- 2 DATE2 Date 8
- 3 DATE3 Date 8
- ** Total ** 25}
-
-
- { Function CalcDate(InDate:DateStr;Days,Months,Years: integer): DateStr;
- (* Add or subtract days,months, or years from two dates. *)
-
- Function CDOW(InDate : DateStr): DayStr;
- (* Returns character day of week - i.e. 'Monday','Tuesday',etc. *)
-
- Function CMonth(InDate : DateStr) : Str9;
- (* Returns character month - i.e. 'March' *)
-
- Function CompDates(Date1,Date2 : DateStr):Word;
- (* Compares two dates and calculates the number of days between them. *)
-
- Function CTOD(InDate: DateStr) : DateType;
- (* Converts a .DBF compatible date field to a word date type. *)
-
- Function DTOC(Julian: DateType) : DateStr;
- (* Converts a word date type to a string compatible with .DBF date fields. *)
-
-
- Function Mon(InDate : DateStr) : Byte;
- (* Returns numeric value for the month in a date. *)
-
- Function TimeNow : TimeStr;
- (* Returns current time in formatted string. *)
-
- Function Today : DateStr;
- (* Returns current date in .DBF date field compatible format. *)
-
- Function ValidDate(InDate : DateStr): boolean;
- (* Checks whether a date is valid. *)}
- Var
- Number : String;
- Num : word;
-
-
- begin
- ClrScr;
- DBOpenFile('datedemo.dbf');
- GetDBRec(1);
- Display;
- Num := CompDates(FieldToStr(1),FieldToStr(2));
- Str(Num:5,Number);
- Writeln('There are ',Number,' days between Date1 and Date2.');
- Writeln('Date1 was a ',RTrim(CDOW(FieldToStr(1))),'.');
- Writeln('The month of Date2 was ',CMonth(FieldToStr(2)),'.');
- Writeln('Date2 plus 1000 days is ',FormDate(CalcDate(FieldToStr(2),1000,0,0)),'.');
- Repl(3,CalcDate(FieldToStr(2),1000,0,0));
- If not ValidDate('19890229') then
- Writeln('February 29, 1989 is not a valid date.');
- Writeln('Today''s date is ',FormDate(Today));
- Writeln('The current time is ',TimeNow,'.');
- PutDBRec(1);
- CloseDBFile;
- Wait;
- ClrScr;
- end.