Q&A

  • 2월에 윤달문제
윤달을 체크하고 spinedit박스에 maxvalue를 잡아주고 년을 바꾼다음 날짜를 바꾸어보고 년을 바꾸면 죽어버립니다. 어케 해야 할지 모르겠네영..

꼭 윤달의 마지막 29일만 체크된후에는 여지없이 에러 다른 경우엔 에러 없음당..





function kkk(year, month : integer) : integer;

const

Months : array[1..12] of SmallInt = (31,28,31,30,31,30,31,31,30,31,30,31);

begin

Result:=Months[Month];

if (Month=2) and ((Year mod 4=0) and (Year mod 100>0) or (Year mod 400=0)) then

Result:=29;

end;



procedure Tgenerolform.SpinEdit3Change(Sender: TObject);

begin

case strtoint(spinedit2.text) of

1 : calendar1.day := strtoint(spinedit3.text);

2 : calendar2.day := strtoint(spinedit3.text);

3 : calendar3.day := strtoint(spinedit3.text);

4 : calendar4.day := strtoint(spinedit3.text);

5 : calendar5.day := strtoint(spinedit3.text);

6 : calendar6.day := strtoint(spinedit3.text);

7 : calendar7.day := strtoint(spinedit3.text);

8 : calendar8.day := strtoint(spinedit3.text);

9 : calendar9.day := strtoint(spinedit3.text);

10 : calendar10.day := strtoint(spinedit3.text);

11 : calendar11.day := strtoint(spinedit3.text);

12 : calendar12.day := strtoint(spinedit3.text);

end;

spinedit3.MaxValue :=

kkk(strtoint(spinedit1.text), strtoint(spinedit2.text));

end



1  COMMENTS
  • Profile
    바람개비 2001.07.04 22:03
    시스템에서 알아서 처리해주므로 해당월의 마지막날짜를 굳이 계산할 필요가 없을듯 합니다.

    해당년도의 3월1일에서 하루를 빼면 2월의 마지막날이 되겠지요?

    Decodedate(encodedate(2000,3,1)-1,Year,Month,Lastday)



    바라미~



    김남규 wrote:

    > 윤달을 체크하고 spinedit박스에 maxvalue를 잡아주고 년을 바꾼다음 날짜를 바꾸어보고 년을 바꾸면 죽어버립니다. 어케 해야 할지 모르겠네영..

    > 꼭 윤달의 마지막 29일만 체크된후에는 여지없이 에러 다른 경우엔 에러 없음당..

    >

    >

    > function kkk(year, month : integer) : integer;

    > const

    > Months : array[1..12] of SmallInt = (31,28,31,30,31,30,31,31,30,31,30,31);

    > begin

    > Result:=Months[Month];

    > if (Month=2) and ((Year mod 4=0) and (Year mod 100>0) or (Year mod 400=0)) then

    > Result:=29;

    > end;

    >

    > procedure Tgenerolform.SpinEdit3Change(Sender: TObject);

    > begin

    > case strtoint(spinedit2.text) of

    > 1 : calendar1.day := strtoint(spinedit3.text);

    > 2 : calendar2.day := strtoint(spinedit3.text);

    > 3 : calendar3.day := strtoint(spinedit3.text);

    > 4 : calendar4.day := strtoint(spinedit3.text);

    > 5 : calendar5.day := strtoint(spinedit3.text);

    > 6 : calendar6.day := strtoint(spinedit3.text);

    > 7 : calendar7.day := strtoint(spinedit3.text);

    > 8 : calendar8.day := strtoint(spinedit3.text);

    > 9 : calendar9.day := strtoint(spinedit3.text);

    > 10 : calendar10.day := strtoint(spinedit3.text);

    > 11 : calendar11.day := strtoint(spinedit3.text);

    > 12 : calendar12.day := strtoint(spinedit3.text);

    > end;

    > spinedit3.MaxValue :=

    > kkk(strtoint(spinedit1.text), strtoint(spinedit2.text));

    > end

    >