1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
UNIT Main;
{$mode objfpc}{$H+}
INTERFACE
USES
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
About, StdCtrls, ExtCtrls;
TYPE
{ TForm1 }
TForm1 = CLASS(TForm)
Bevel1: TBEVEL;
LanguageButton: TBUTTON;
EndButton: TBUTTON;
AboutButton: TBUTTON;
CalculateButton: TBUTTON;
Edit1: TEDIT;
AshWednesdayLabel: TLABEL;
YearLabel: TLABEL;
GoodFridayLabel: TLABEL;
EasterMondayLabel: TLABEL;
AscensionDayLabel: TLABEL;
PentecostLabel: TLABEL;
CorpusCristiLabel: TLABEL;
Listbox1: TLISTBOX;
PROCEDURE Button1CLICK(Sender: TObject);
PROCEDURE Button2CLICK(Sender: TObject);
PROCEDURE Button3CLICK(Sender: TObject);
PROCEDURE Form1SHOW(Sender: TObject);
procedure LanguageButtonCLICK(Sender: TObject);
procedure Listbox1DrawItem(AControl: TWinControl; Index: Integer;
ARect: TRect; AState: TOwnerDrawState);
PUBLIC
FUNCTION CalcEasterday(aYear: Word): TDateTime;
END;
VAR
Form1: TForm1;
IMPLEMENTATION
{$R main.lfm}
PROCEDURE TForm1.Button1CLICK(Sender: TObject);
VAR
Easter: TDateTime;
aYear : WORD;
BEGIN
ListBox1.Clear;
TRY
aYear := StrToInt(Edit1.Text);
EXCEPT
if LanguageButton.Caption = 'English' then
ShowMessage('Fehlerhafte Eingabe des Jahrs!')
else
ShowMessage('Incorrect input of the year!');
Exit;
END;
Easter := CalcEasterday(aYear);
ListBox1.Items.Add(DateToStr(Easter - 46));
ListBox1.Items.Add(DateToStr(Easter - 2));
ListBox1.Items.Add(DateToStr(Easter + 1));
ListBox1.Items.Add(DateToStr(Easter + 39));
ListBox1.Items.Add(DateToStr(Easter + 50));
ListBox1.Items.Add(DateToStr(Easter + 60));
END;
PROCEDURE TForm1.Button2CLICK(Sender: TObject);
BEGIN
Close;
END;
procedure TForm1.Button3CLICK(Sender: TObject);
begin
AboutBox.ShowModal;
end;
PROCEDURE TForm1.Form1SHOW(Sender: TObject);
BEGIN
Button1CLICK(Sender);
END;
procedure TForm1.LanguageButtonCLICK(Sender: TObject);
begin
if LanguageButton.Caption='English' then begin
LanguageButton.Caption:='Deutsch';
EndButton.Caption:='Exit';
AboutButton.Caption:='About';
CalculateButton.Caption:='Calculate';
AshWednesdayLabel.Caption:='Ash Wednesday';
YearLabel.Caption:='Year';
GoodFridayLabel.Caption:='Good Friday';
EasterMondayLabel.Caption:='Easter Monday';
AscensionDayLabel.Caption:='Ascension Day';
PentecostLabel.Caption:='Pentecost';
CorpusCristiLabel.Caption:='Corspus Cristi';
end else begin
LanguageButton.Caption:='English';
EndButton.Caption:='Exit';
AboutButton.Caption:='Info';
CalculateButton.Caption:='Berechne';
AshWednesdayLabel.Caption:='Aschermittwoch';
YearLabel.Caption:='Jahr';
GoodFridayLabel.Caption:='Karfreitag';
EasterMondayLabel.Caption:='Ostermontag';
AscensionDayLabel.Caption:='Himmelfahrt';
PentecostLabel.Caption:='Pfingsten';
CorpusCristiLabel.Caption:='Fronleichnam';
end;
end;
procedure TForm1.Listbox1DrawItem(AControl: TWinControl; Index: Integer;
ARect: TRect; AState: TOwnerDrawState);
var
ts: TTextStyle;
begin
Listbox1.Canvas.FillRect(ARect);
ts := Listbox1.Canvas.TextStyle;
ts.Alignment := taCenter;
Listbox1.Canvas.TextRect(ARect, ARect.Left+2, ARect.Top, Listbox1.Items[Index], ts);
end;
FUNCTION TForm1.CalcEasterday(aYear: WORD): TDateTime;
VAR
A, B, C, D, E, F, G, H, I, J, K, L, M, N: INTEGER;
vDay, vMonth: WORD;
BEGIN
A := aYear MOD 19;
B := aYear DIV 100;
C := aYear MOD 100;
D := B DIV 4;
E := B MOD 4;
F := (B + 8) DIV 25;
G := (B - F + 1) DIV 3;
H := (19 * A + B - D - G + 15) MOD 30;
I := C DIV 4;
J := C MOD 4;
K := (32 + 2 * E + 2 * I - H - J) MOD 7;
L := (A + 11 * H + 22 * K) DIV 451;
M := (H + K - 7 * L + 114) DIV 31;
N := (H + K - 7 * L + 114) MOD 31;
vDay := N + 1;
IF M = 3 THEN vMonth := 3 ELSE vMonth := 4;
Result := EncodeDate(aYear, vMonth, vDay);
END;
END.
|