home *** CD-ROM | disk | FTP | other *** search
- UNIT CalUnit2;
-
- INTERFACE
- USES CRT,DOS,CalUnit;
- TYPE
- DateSelect = OBJECT( Calendar )
- ThisDay : Word;
- CONSTRUCTOR Init( Month, Year, Day: Integer );
- PROCEDURE DrawCalendar;
- PROCEDURE SetDay( Day: Integer );
- FUNCTION GetDay: Integer;
- END;
-
- IMPLEMENTATION
- CONSTRUCTOR DateSelect.Init
- ( Month, Year, Day: Integer );
- BEGIN
- SetYear( Year );
- SetMonth( Month );
- SetDay( Day );
- DrawCalendar
- END;
-
- PROCEDURE DateSelect.DrawCalendar;
- VAR
- CurYear,CurMonth,CurDay,CurDow,
- ThisDOW, DummyDate : Word;
- I,DayPos,NbrDays : Byte;
- CONST
- DOM: ARRAY[1..12] OF Byte =
- (31,28,31,30,31,30,31,31,30,31,30,31);
- MonthName: ARRAY[1..12] OF String[3] =
- ('Jan','Feb','Mar','Apr','May','Jun',
- 'Jul','Aug','Sep','Oct','Nov','Dec');
- BEGIN
- GetDate(CurYear,CurMonth,CurDay,CurDow);
- DummyDate := 1;
- SetDate(ThisYear,ThisMonth,DummyDate);
- {ThisDOW stands for This day of the week}
- GetDate(ThisYear,ThisMonth,DummyDate,ThisDOW);
- SetDate(CurYear,CurMonth,CurDay);
- WriteLn(' ',MonthName[ThisMonth],
- ' ',ThisYear);
- WriteLn;
- WriteLn(' S M T W R F S');
- NbrDays := DOM[ThisMonth];
- {Check for leap year, which occurs when the
- year is evenly divisible by 4 and not evenly
- divisable by 100 or if the year is evenly
- divisable by 400}
- IF ((ThisMonth = 2) AND
- ((ThisYear MOD 4 = 0) AND
- (ThisYear MOD 100 <> 0))
- OR (ThisYear MOD 400 = 0))
- THEN NbrDays := 29;
- FOR I:= 1 TO NbrDays DO
- BEGIN
- DayPos := ThisDOW * 4 + 2; {Position day #}
- GotoXY(DayPos,WhereY);
- Inc(ThisDOW);
- IF I = ThisDay THEN HighVideo;
- Write(I:3); NormVideo;
- IF ThisDOW > 6 THEN
- BEGIN
- ThisDOW := 0;
- WriteLn
- END
- END;
- WriteLn;
- WriteLn;
- WriteLn( 'The current date is ', ThisMonth,
- '/', ThisDay, '/', ThisYear )
- END;
-
- PROCEDURE DateSelect.SetDay( Day: Integer );
- BEGIN
- ThisDay := Day
- END;
-
- FUNCTION DateSelect.GetDay: Integer;
- BEGIN
- GetDay := ThisDay
- END;
-
- END.