枚举某一时间段的有多少正点

var
myDay:integer;
leepDay:integer;
StaDateTime,EndDateTime:TDateTime;
Year1,Month1,Day1,Hour1,Minute1,
Second1,MilliSecond1:Word;
Year2,Month2,Day2,Hour2,Minute2,
Second2,MilliSecond2:Word;
i,j:integer;
s1,s2:string;
d:double;
begin
StaDateTime:=StrToDateTime('2005-12-10 0:00:00');
EndDateTime:=StrToDateTime('2005-12-10 12:00:00');
DecodeDateTime(StaDateTime,Year1,Month1,Day1,Hour1,Minute1,Second1,MilliSecond1);
DecodeDateTime(EndDateTime,Year2,Month2,Day2,Hour2,Minute2,Second2,MilliSecond2);
if EndDateTime-StaDateTime<=0 then d:=0 else
d:=EndDateTime-StaDateTime;
s1:=FloatToStr(d);
s1:=Copy(S1,1,Pos('.',s1)-1);
i:=StrToInt(s1);
i:=i*24;
if Hour2-Hour1>0 then i:=i+Hour2-Hour1 else
i:=i+24+Hour2-Hour1;
i:=i+1;
if i>744 then i:=0;
for j:=1 to i-1 do
  begin
    if Hour1<23 then
    Hour1:=Hour1+1
    else
    begin
       if Year1 mod 4=0 then leepDay:=29 else leepDay:=28;
      //判断月份的天数。
      case Month1 of
      1: myDay:=31;
      2: myDay:=leepDay;
      3: myDay:=31;
      4: myDay:=30;
      5: myDay:=31;
      6: myDay:=30;
      7: myDay:=31;
      8: myDay:=31;
      9: myDay:=30;
      10: myDay:=31;
      11: myDay:=30;
      12: myDay:=31;
      end;
      if Hour1+1=24 then
      begin
        if Day1<myDay then
        begin
          if Month1<12 then
          begin
            Day1:=Day1+1;
          end else
          begin
            Year1:=Year1+1;
            Month1:=1;
          end;
        end else
        begin
          if Month1<12 then
          begin
            Month1:=Month1+1;
          end else
          begin
            Year1:=Year1+1;
            Month1:=1;
          end;
          Day1:=1;
        end;
        Hour1:=0;
      end;
    end;
    S2:=IntToStr(Year1)+'-'+IntToStr(Month1)+'-'+IntToStr(Day1)+' '+IntToStr(Hour1)+':00:00';
    ShowMessage(s2);
    end;
  end;
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值