我做出来了,不知道和lldhz的想法是否类似?
procedure TForm1.Button1Click(Sender: TObject);
var
part: array[1..5] of Tdatetime;
i, ks, js: integer;
begin
part[1] := strtotime('0:00');
part[2] := strtotime('7:00');
part[3] := strtotime('12:00');
part[4] := strtotime('22:00');
part[5] := strtotime('23:59');
ks := 0;
js := 0;
for i := 2 to 4 do
begin
if strtotime(FlatMaskEdit1.Text) <= part then
begin
if strtotime(FlatMaskEdit2.Text) >= part then
ks := i;
break;
end;
end;
for i := 2 to 5 do
begin
if strtotime(FlatMaskEdit2.Text) <= part then
begin
if strtotime(FlatMaskEdit1.Text) <= part[i - 1] then
js := i - 1;
break;
end;
end;
memo1.Lines.Clear;
if (ks <> 0) and (js <> 0) then
for i := ks to js do
memo1.Lines.Add('00:' + timetostr(part));
end;