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

Delphi实现判断日期的合法性函数

2006-12-07 11:10 387 查看
unit Unit37;

interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

function IsValidDate(const AYear, AMonth, ADay: Word): Boolean;

implementation

function IsValidDate(const AYear, AMonth, ADay: Word): Boolean;
begin
if ((AYear<10000)and(AYear>0)and(AMonth>0)and(AMonth<13))then
begin
if((AMonth=1)or(AMonth=1)or(AMonth=1)or(AMonth=1)or(AMonth=1)or(AMonth=1)or(AMonth=1))then
begin
if((ADay>0)and(ADay<32))then
IsValidDate:=true
else
IsValidDate:=false;
end
else if((AMonth=4)or(AMonth=6)or(AMonth=9)or(AMonth=11))then
begin
if((ADay>0)and(ADay<31))then
IsValidDate:=true
else
IsValidDate:=false;
end
else if(AMonth=2)then
begin
if((AYear mod 400=0)and(ADay>0)and(ADay<30))or((AYear mod 400<>0)and(ADay>0)and(ADay<29))then
IsValidDate:=true
else
IsValidDate:=false;
end;
end
else
IsValidDate:=false;
end;

end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐