[fpc-pascal]Week Day
Rich Pasco
pasco at acm.org
Thu Apr 19 00:56:57 CEST 2001
No assembler is required; it's easily done in Pascal:
function Weekday(D,M,Y: word): word;
(* Input D=day (1..31), M=month(1..12), Y=year(e.g. 2001) *)
(* Returns 0=Sunday, 1=Monday, ... 6=Saturday *)
const
FD: array[1..12] of byte = (6,2,2,5,0,3,5,1,4,6,2,4);
var
Y1: integer;
begin
if M > 2 then Y1 := Y else Y1 := Y-1;
WeekDay := ((D+(Y1 div 4)-(Y1 div 100)+(Y1 div 400)+Y+FD[M]) mod 7);
end;
I hope this helps.
- Rich
More information about the fpc-pascal
mailing list