본문 바로가기
Delphi/프로시저-함수

주민등록번호 성인인증

by MonoSoft 2024. 5. 14.
728x90
반응형

주민등록번호 성인인증

728x90

 

 

 

function IsUserAudult(jumin : string):boolean;

var

juminleng, lastnum : integer;

yy, mm, dd : string;

nyy, nmm, ndd : integer;

iyy, imm, idd : integer;

ryy, rmm : integer;

isAudult : boolean;

begin

 

result := false;

 

nyy := strtoint(Formatdatetime('YYYY', now));

nmm := strtoint(Formatdatetime('MM', now));

ndd := strtoint(Formatdatetime('DD', now));

 

juminleng := length(jumin);

 

if juminleng < 6 then

exit

else

if juminleng = 6 then

begin

yy := copy(jumin, 1, 2);

mm := copy(jumin, 3, 2);

dd := copy(jumin, 5, 2);

lastnum := 0;

end

else

if juminleng > 6 then

begin

yy := copy(jumin, 1, 2);

mm := copy(jumin, 3, 2);

dd := copy(jumin, 5, 2);

lastnum := strtoint(copy(jumin, 7, 1));

end;

 

case lastnum of

0..2 :

begin

iyy := strtoint('19' + yy)

end;

3..4 :

begin

iyy := strtoint('20' + yy)

end;

end;

 

imm := strtoint(mm);

idd := strtoint(dd);

ryy := nyy - iyy;

if ryy = 20 then

begin

if nmm = imm then

begin

if ndd = idd then

isAudult := true

else

begin

if ndd > idd then

isAudult := false

else

isAudult := true;

end

end

else

begin

if nmm > imm then

isAudult := false

else

isAudult := true;

end;

end

else

if ryy <= 19 then

isAudult := false

else

if ryy >= 21 then

isAudult := true;

result := isAudult;

end;

 

728x90
반응형

댓글