Difference between revisions of "leap year/de"

From Free Pascal wiki
Jump to navigationJump to search
m
Line 36: Line 36:
 
<br>
 
<br>
 
--[[User:Olaf|Olaf]] 10:47, 23 April 2013 (UTC)
 
--[[User:Olaf|Olaf]] 10:47, 23 April 2013 (UTC)
{{AutoCategory}}[[Category:Code Parts/de]][[Category:Mathe/de]]
+
 
 +
 
 +
{{AutoCategory}}
 +
[[Category:Code Snippets/de]]
 +
[[Category:Mathe/de]]

Revision as of 00:35, 30 October 2015

Deutsch (de)

Zurück zur Seite Code Beispiele.

Dieses Beispiel prüft, ob das Jahr ein (christliches) Schaltjahr ab dem Jahr 1582 ist.
Alternativ gibt es dazu in der Unit Sysutils die Funktion leap year (leap year = Schaltjahr).

function funIstSchaltjahr(wrdJahr: word): integer;
const
  conKalenderumstellung = 1583;
  conFehler = -1;
  conFalsch = 0;
  conWahr = 1;

begin

  Result := conFehler;
  // Prüft auf die Richtigkeit des Kalenderjahres
  if wrdJahr < conKalenderumstellung then
    exit;

  Result := conFalsch;

  if (wrdJahr mod 4) = 0 then
    Result := conWahr;
  if (wrdJahr mod 100) = 0 then
    Result := 0;
  if (wrdJahr mod 400) = 0 then
    Result := conWahr;

end;



--Olaf 10:47, 23 April 2013 (UTC)