Q&A

  • 날짜의 정확성 여부...
제가 날짜를 만약 MaskEdit에서 20010231이라고 입력하면 사실 02은 28일까지 밖에

없으므로 Error라는 메세지가 나오게 하려면 어떻게 해야죠.?



1  COMMENTS
  • Profile
    홍성락 2001.08.15 04:59
    이원택 wrote:

    > 제가 날짜를 만약 MaskEdit에서 20010231이라고 입력하면 사실 02은 28일까지 밖에

    > 없으므로 Error라는 메세지가 나오게 하려면 어떻게 해야죠.?

    /////////////////////////////////////////////////////////////

    SysUtils 유닛의 DoEncodeDate를 조금 고쳐봤습니다.

    function TForm1.OKDate(SDate: string): Boolean;

    var

    Year, Month, Day: integer;

    DayTable: PDayTable;

    begin

    Result := True;

    try

    Year := StrToInt(copy(SDate,1,4));

    Month:= StrToInt(copy(SDate,5,2));

    Day := StrToInt(copy(SDate,7,2));

    DayTable := @MonthDays[IsLeapYear(Year)];

    if not((Year >= 1) and (Year <= 9999) and (Month >= 1) and (Month <= 12) and

    (Day >= 1) and (Day <= DayTable^[Month])) then begin

    Result := False;

    end;

    except

    Result := False;

    end;

    end;