procedure TForm1.Button1Click(Sender: TObject);
var
year:string;
month:integer;
day,i,j:integer;
dt:TDate;
begin
year:=form1.Edit1.Text;
for month:=1 to 12 do
begin
dt:=strtodate(year+'-'+inttostr(month)+'-'+'1');
day:=form1.getdays(dt);
for i:=1 to day do
begin
j:=dayoftheweek(strtodate(year+'-'+inttostr(month)+'-'+inttostr(i)));
if (j=6) or (j=7) then
begin
form1.ListBox1.Items.Add(year+'-'+inttostr(month)+'-'+inttostr(i));
end;
end;
end;
end;
function TForm1.getdays(var dt: TDate): integer;
var
d:TDate;
year,month,day:word;
i,j,m:integer;
s,s1:string;
str:TStringList;
begin
str:=TStringList.Create;
str.Clear;
decodedate(incmonth(dt,1),year,month,day);
d:=encodedate(year,month,1)-1;
s:=datetostr(d);
i:=length(s);
for j:=1 to i do
begin
if s[j]='-' then
begin
str.Add(inttostr(j));
end;
end;
s1:=copy(s,strtoint(str.Strings[1])+1,i-strtoint(str.Strings[1]));
result:=strtoint(s1);
end;