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;
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;
相关文章推荐
- 判断输入字符串是否是有效时间
- 2014华为机试-判断输入的字符串是不是一个有效的IP地址
- 华为oj-判断输入的字符串是不是一个有效的IP地址
- 判断一个字符串是否是时间表达式(DELPHI)
- 判断输入的字符串是不是一个有效的IP地址
- 判断二个字符串是不是"相同字母异序词"
- C# 判断一个字符串是否是时间格式
- Delphi判断字符串是否是数字、字母、大小写字母
- 判断一个链表是不是回文数,要求O(n)时间
- JAVA 判断一个字符串是不是一个合法的日期格式format.setLenient(false);
- [C/C++笔面试]判断字符串是不是回文
- 判定一个字符串是否为有效时间的函数
- 判断字符串是否为时间格式
- 快速判断两个字符串是不是兄弟串(两个字符串中的字符相同)
- 判断字符串是不是数字
- 字符串操作(人民币转成大写/全角字符转半角字符/去掉字符串中重复的子字符串/过滤常见特殊字符/反过滤特殊字符/判断是不是合法手机/字符串匹配的算法)
- IOS判断字符串是不是纯数字的方法总结
- python判断一个字符是不是在一个字符串中关键字in ,not in
- 如何判断一个网络路径是不是有效路径
- 判断一个字符串是否为有效ip地址