easter.pas 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Program easter;
  2. {
  3. easter v1.0
  4. © 1995 by Andreas Tetzl
  5. FREEWARE
  6. This is a little program to calculate the date of
  7. easter for years between 1583 and 2299.
  8. Start it in a shell with the year as argument.
  9. }
  10. {
  11. Translated to fpc pascal.
  12. 21 Mar 2001.
  13. [email protected]
  14. }
  15. uses amigados;
  16. const version : pchar = '$VER: easter v1.0 (3-Nov-95) by Andreas Tetzl';
  17. VAR i,a,b,c,d,e,m,n : Integer;
  18. year, month, day : longint;
  19. BEGIN
  20. if (ParamStr(1) = '?') or (ParamStr(1) = '') then
  21. BEGIN
  22. Writeln('YEAR/N');
  23. halt(20);
  24. END;
  25. i:=StrToLong(ParamStr(1),year);
  26. if (year<1583) or (year>2299) then
  27. BEGIN
  28. Writeln('only years between 1583 and 2299 allowed');
  29. halt(20);
  30. END;
  31. Case year of
  32. 1583..1699 : BEGIN m:=22; n:=2; END;
  33. 1700..1799 : BEGIN m:=23; n:=3; END;
  34. 1800..1899 : BEGIN m:=23; n:=4; END;
  35. 1900..2099 : BEGIN m:=24; n:=5; END;
  36. 2100..2199 : BEGIN m:=24; n:=6; END;
  37. 2200..2299 : BEGIN m:=25; n:=0; END;
  38. end;
  39. a:=year mod 19;
  40. b:=year mod 4;
  41. c:=year mod 7;
  42. d:=(19*a+m) mod 30;
  43. e:=(2*b+4*c+6*d+n) mod 7;
  44. day:=22+d+e;
  45. if day<=31 then
  46. month:=3
  47. else
  48. BEGIN
  49. month:=4;
  50. day:=d+e-9;
  51. END;
  52. if (month=4) and (day=26) then day:=19;
  53. if (month=4) and (day=25) and (d=28) and (e=6) and (a>10) then day:=18;
  54. Write(year,'-');
  55. if month=3 then Write('Mar') else Write('Apr');
  56. Writeln('-',day);
  57. END.