随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

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.


DateUtils-Function
posted on 2009-05-21 11:29  万一  阅读(...)  评论(...编辑  收藏