本文整理自网络,侵删。
IsValidDateTime、IsValidDate、IsValidTime、IsValidDateDay ... 判断时间是否合法
DateUtils.IsValidDateTime
DateUtils.IsValidDate
DateUtils.IsValidTime
DateUtils.IsValidDateDay
DateUtils.IsValidDateWeek
DateUtils.IsValidDateMonthWeek
//可用下面几个过程抛出异常:
DateUtils.InvalidDateDayError
DateUtils.InvalidDateMonthWeekError
DateUtils.InvalidDateTimeError
DateUtils.InvalidDateWeekError
DateUtils.InvalidDayOfWeekInMonthError
--------------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses DateUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
b: Boolean;
begin
b := IsValidDateTime(2009, 5, 21, 11, 22, 33, 999); //True
b := IsValidDateTime(2009, 5, 21, 11, 22, 33, 9999); //False
b := IsValidDate(2009, 5, 21); //True
b := IsValidDate(2009, 5, 32); //False
b := IsValidTime(11, 22, 33, 0); //True
b := IsValidTime(11, 22, 61, 0); //False
b := IsValidDateDay(2009, 141); //True
b := IsValidDateDay(2009, 366); //False
b := IsValidDateWeek(2009, 21, 7); //True
b := IsValidDateWeek(2009, 21, 8); //False
b := IsValidDateMonthWeek(2009, 5, 3, 7); //True
b := IsValidDateMonthWeek(2009, 5, 3, 8); //False
// ShowMessage(BoolToStr(b, True));
end;
end.
相关阅读 >>
Delphi leftstr 返回字符串左边指定个数的新字符(串)
更多相关阅读请进入《Delphi》频道 >>