Is Leap Year ?

 




Function IsLeapYear ( Date : String ) : integer ;

Var

   dTemp       : TDate ;

Begin

   dTemp := StrToDate ( Date ) ;

   Result := trunc ( dTemp -

      StrToDate ( FormatDateTime ( '01.01.yyyy' , dTemp ) ) ) + 1 ;

End ;

 

Example :

 

Procedure TForm1.Button2Click ( Sender : TObject ) ;

Begin

   Caption := IntToStr ( IsLeapYear ( '31.12.1999' ) ) ;

End ;

 


Back Home Foward