Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!unido!rmi!infoac!infohh!natec From: natec@infohh.rmi.de (NATEC Institut GmbH) Newsgroups: comp.lang.pascal Subject: Day-of-week algorithm Message-ID: <522@infohh.rmi.de> Date: 12 Apr 89 06:31:00 GMT Reply-To: natec@infohh.rmi.de (NATEC Institut GmbH) Organization: RMI Net * Aachen/Hamburg/Flensburg * W.Germany Lines: 40 try this approximation: Function DayOfWeek ( Day, Month : Byte; Year : Word ) : Byte; Function Leap : Byte; begin if Month>2 then Leap:=8 else Leap:=0 end; begin DayOfWeek:= Trunc(Day+1+Int(Month/0.39)+(Year+Leap)/4+Int(Year*0.99)+ Int(Year/400)) mod 7; end; - and, by the way, this is Easter: Function Easter ( Year : Word ) : String; { GAUSSIAN } var d,e,f,M,N : Byte; a,s : String; begin if (Year<1700) or (Year>2199) then Easter:= 'don''t know' else begin Str (Year,a); M:= 24; if Year<1900 then M:= 23; N:= Trunc(Year/100) - 14; if N = 7 then N:= 6; d:= (19*(Year mod 19)+M) mod 30; e:= ( 2*(Year mod 4)+4*(Year mod 7)+6*d+N) mod 7; if 22+d+e < 32 then begin Str(22+d+e,s); Easter:= s+'.Mar.'+a end else begin f:= d+e-9; if f = 26 then f:= 19; if (f = 25) and (d = 28) and (Year mod 19 > 10) then f:= 18; Str (f,s); Easter:= s+'.Apr.'+a end end end; Dr Gerd C Schmerse | natec@infohh.rmi.de | ___ NATEC Institut | 49 40 88300170 (fax) | /o o\ Hamburg, W.Germany | 49 40 88300124 (voice) | -m-"-U-"-m-