[Setup]
AppName = MyApp
AppVerName = MyApp
DefaultDirname = {pf}\MyApp
OutputDir=.
[code]
// Високосный год или нет
function is_leap_year( year: Integer ): Boolean;
begin
if ( ( year mod 4 = 0 ) and ( ( year mod 100 <> 0 ) or ( year mod 400 <> 0 ) ) ) then
Result := True
else
Result := False;
end;
function daytable( month, year: Integer ): Integer;
var
days: array[1..12] of Integer;
begin
days[ 1 ] := 31; //Jan
days[ 2 ] := 28; //Feb
days[ 3 ] := 31; //March
days[ 4 ] := 30; //April
days[ 5 ] := 31; //May
days[ 6 ] := 30; //June
days[ 7 ] := 31; //July
days[ 8 ] := 31; //Aug
days[ 9 ] := 30; //Sep
days[ 10 ] := 31; //Oct
days[ 11 ] := 30; //Nov
days[ 12 ] := 31; //Dec
if is_leap_year( year ) = True then
Result := 29
else
Result := 28;
if( month <> 2 ) then Result := days[ month ];
end;
// Num - на сколько увеличить текущую дату
function dateoper( Num: Integer ) : String;
var
//dd, mm, yy : String;
dd, mm, yy: Integer;
Day, mDay: Integer;
begin
dd := StrToInt( GetDateTimeString( 'd', '-', ':' ) ); // День
mm := StrToInt( GetDateTimeString( 'm', '-', ':' ) ); // Месяц
yy := StrToInt( GetDateTimeString( 'yyyy', '-', ':' ) ); // Год
mDay := daytable( mm, yy );
if ( dd + Num ) > mDay then
begin
Day := Num - ( mDay - dd );
Result := Format('%d:%d:%d', [ Day, mm + 1, yy ])
end
else
Result := Format('%d:%d:%d', [dd + Num, mm, yy])
end;
function InitializeSetup: Boolean;
begin
MsgBox( dateoper( 25 ), mbInformation, MB_OK );
end;