{ Return the number of days in the given month in the given year. } function NumberOfDaysIn (month, year: integer): integer; { Return 0 to represent no leap day, or 1 if it's a leap year. } function LeapDay (year: integer): integer; begin if (year mod 4 = 0) and (year mod 100 <> 0) then begin LeapDay := 1 end else if year mod 400 = 0 then begin LeapDay := 1 end else begin LeapDay := 0; end; end; begin {NumberOfDaysIn} case month of JAN, MAR, MAY, JUL, AUG, OCT, DEC: NumberOfDaysIn := 31; FEB: NumberOfDaysIn := 28 + LeapDay (year); APR, JUN, SEP, NOV: NumberOfDaysIn := 30; end; end {NumberOfDaysIn};