Delphi 判断字符串是不是有效的时间

function  TForm_MEA_CHG.isEffectsDate(astrdatetime:string):Boolean;  //判断是不是有效的时间
var
  jstrYear,jstrMonth,jstrday:string;
  IMonth:integer;
begin
  Result:=true;
  jstrYear:=Copy(astrdatetime,1,4);
  jstrMonth:=Copy(astrdatetime,5,2);
  jstrDay:=Copy(astrdatetime,7,2);
  if (jstrMonth='01') or (jstrMonth='03') or (jstrMonth='05') or (jstrMonth='07')
     or (jstrMonth='08') or (jstrMonth='10') or (jstrMonth='12')  then
  begin
    IMonth:= 31;
  end
  else if (jstrMonth='04') or (jstrMonth='06') or (jstrMonth='08') or (jstrMonth='11') then
  begin
    IMonth:= 30;
  end
  else if ((StrToInt(jstrYear) mod 4 = 0) and (StrToInt(jstrYear) mod 100 <> 0)) or (StrToInt(jstrYear) mod 400 = 0) then
    IMonth:= 29
  else
    IMonth:= 28;

  if StrToInt(jstrday)>IMonth then
  begin
    Result:=False;
  
  end;


end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值