您的位置:首页 > 编程语言 > Delphi

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

2010-12-09 20:13 323 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: