Easter date/de: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + | Zurück zur Seite [[code examples/de|Code Beispiele]]. | |
| 2 | 2 | ||
| 3 | - | ||
| 4 | - | ||
| 3 | + | Dieses Beispiel berechnet das Osterdatum (Ostersonntag) der Westkirchen nach der Formel von Carl Friedrich Gauß für den Zeitraum von 1583 - 8702. | |
| 5 | 4 | ||
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 5 | + | ``` pascal | |
| 9 | 6 | uses | |
| 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 | - | ||
| 7 | + | SysUtils, DateUtils, Dialogs; | |
| 8 | + | ||
| 9 | + | ... | |
| 10 | + | ||
| 11 | + | function funOstersonntag(wrdJahr: word): TDate; | |
| 12 | + | // Osterfunktion nach Carl Friedrich Gauß (1800). Rückgabewert | |
| 13 | + | // ist das Datum des Ostersonntags im angegebenen Jahr | |
| 14 | + | // Gültigkeitsbereich: 1583 - 8702 | |
| 15 | + | var | |
| 16 | + | a: integer; | |
| 17 | + | b: integer; | |
| 18 | + | c: integer; | |
| 19 | + | d: integer; | |
| 20 | + | e: integer; | |
| 21 | + | f: integer; | |
| 22 | + | wrdTage: word; | |
| 23 | + | wrdMonat: word; | |
| 24 | + | ||
| 25 | + | begin | |
| 26 | + | ||
| 27 | + | // Prüft, ob das Jahr korrekt ist | |
| 28 | + | if wrdJahr < 1583 then | |
| 29 | + | begin | |
| 30 | + | ShowMessage('Das Jahr ist zu klein und liegt vor dem Jahr 1583.'); | |
| 31 | + | Exit; | |
| 32 | + | end; | |
| 33 | + | ||
| 34 | + | if wrdJahr > 8702 then | |
| 35 | + | begin | |
| 36 | + | ShowMessage('Das Jahr ist zu groß und liegt nach dem Jahr 8702.'); | |
| 37 | + | Exit; | |
| 38 | + | end; | |
| 39 | + | ||
| 40 | + | // Die Gauss-Formel | |
| 41 | + | a := wrdJahr mod 19; | |
| 42 | + | b := wrdJahr div 100; | |
| 43 | + | c := (8 * b + 13) div 25 - 2; | |
| 44 | + | d := b - (wrdJahr div 400) - 2; | |
| 45 | + | e := (19 * (wrdJahr mod 19) + ((15 - c + d) mod 30)) mod 30; | |
| 46 | + | ||
| 47 | + | if e = 28 then | |
| 48 | + | if a > 10 then | |
| 49 | + | e := 27 | |
| 50 | + | else if e = 29 then | |
| 51 | + | e := 28; | |
| 52 | + | ||
| 53 | + | f := (d + 6 * e + 2 * (wrdJahr mod 4) + 4 * (wrdJahr mod 7) + 6) mod 7; | |
| 54 | + | ||
| 55 | + | if (e + f + 22) > 31 then | |
| 56 | + | begin | |
| 57 | + | wrdMonat := 4; | |
| 58 | + | wrdTage := ((e + f + 22) - 31); | |
| 59 | + | end | |
| 60 | + | else | |
| 61 | + | begin | |
| 62 | + | wrdMonat := 3; | |
| 63 | + | wrdTage := (e + f + 22); | |
| 64 | + | end; | |
| 65 | + | ||
| 66 | + | // Rückgabewert als Datum bereitstellen | |
| 67 | + | Result := EncodeDate(wrdJahr, wrdMonat, wrdTage); | |
| 68 | + | ||
| 69 | + | end; | |
| 73 | 70 | ``` | |
| 74 | 71 | ||
| 75 | 72 | --- | |
| 76 | - | ||
| 73 | + | *From the Free Pascal wiki, page "Easter date/de", as it stood on 2020-02-14 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 74 | + | Category: Code Snippets/de | |
| 75 | + | Category: Deutsch | |
| 76 | + | Category: Mathe/de |
