uses DateUtils, Types;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
FirstDate: TDateTime;
Year, Month, Day: Word;
begin
ListBox1.Clear;
DecodeDate(Today, Year, Month, Day);
FirstDate := EncodeDate(Year, 1, 1); //今年的第一天
//七天之内必有一个星期四
for i := 1 to 7 do begin
FirstDate := IncDay(FirstDate);
if DayOfWeek(FirstDate) = 5 then break;
end;
ListBox1.Items.Add(FormatDateTime('dddddd', FirstDate));
//利用周期性,从第一个星期四开始后的线隔七天均是星期四
for i := 1 to WeeksInYear(Today) do begin
FirstDate := IncDay(FirstDate, DaysPerWeek);
if CompareDate(FirstDate, EndOfTheYear(Today)) = LessThanValue then
ListBox1.Items.Add(FormatDateTime('dddddd', FirstDate));
end;
end;