Category : Miscellaneous Language Source Code
Archive   : ADATUT12.ZIP
Filename : TOMORROW.ANS

 
Output of file : TOMORROW.ANS contained in archive : ADATUT12.ZIP

-- Our solution to Outside Assignment 3:
separate (NEXTDATE)
function TOMORROW(TODAY : in DATE) return DATE is
LENGTH : array(MONTH_TYPE) of DAY_SUBTYPE :=
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
ANSWER : DATE;
begin
if TODAY.YEAR mod 4 = 0 and
(TODAY.YEAR mod 100 /= 0 or TODAY.YEAR mod 400 = 0) then
LENGTH(FEB) := 29;
end if;
if TODAY.DAY /= LENGTH(TODAY.MONTH) then -- Not end of month.
ANSWER := (TODAY.DAY + 1, TODAY.MONTH, TODAY.YEAR);
elsif TODAY.MONTH /= DEC then -- End of month, but not end of year.
ANSWER := (1, MONTH_TYPE'SUCC(TODAY.MONTH), TODAY.YEAR);
else -- End of year.
ANSWER := (1, JAN, TODAY.YEAR + 1);
end if;
return ANSWER;
end TOMORROW;