ผมลองแก้เองแล้วนะครับ อาจไม่ค่อยน่าดู code ซักเท่าไร แต่ก็คำนวณ ตรงใช้ได้ครับ
จาก
no:=JD-JD5+1;
จากตรงนี้ครับ
if nmonth<5 then m:=4 else m:=5;
lcheck:=True;
lwork:=False;
i:=0;
while not lwork do
begin
i:=i+1;
n:=no;
nmod:=m mod 2;
if nmod=1 then _day:=29 else _day:=30;
if (m=7 and _index=2) then _day:=_day+1;
if nmonth<5 then m:=m-1 else m:=m+1;
if m<5 then no:=no+_day else no:=no-_day;
// showmessage(inttostr(m-1)+'-'+inttostr(_index)+'-'+booltostr(lcheck)+#13+inttostr(nmod)+#13+inttostr(_day)+#13+inttostr(n)+'-'+inttostr(no));
if m=9 then
if _index=1 then
if lcheck then
begin
lcheck:=False;
m:=8;
end;
if nmonth<5 then lwork:=no>0 else lwork:=no<=_day;
if i>12 then lwork:=true;
end; n:=dayofweek(nowdate);
cthaiday:=formatdatetime('dddd',nowdate); //getsqldata('select name from thaiday where id="'+inttostr(n)+'" ');
ram:='';
if no<16 then ram:='ขึ้น '+inttostr(no) else ram:='แรม '+inttostr(no-15);
ram:=ram+' ค่ำ';
if nmonth<5 then m:=m+1;
แก้เป็น
ดังนี้ครับ
if _index=1 then
begin
if (no >=-117)and (no<=-89) then begin no:=no+118;m:=1; end else
if (no >=-88) and (no<=-59) then begin no:=no+89;m:=2; end else
if (no >=-58) and (no<=-30) then begin no:=no+59;m:=3; end else
if (no >=-29) and (no<=0) then begin no:=no+30;m:=4; end else
if (no >=1) and (no<=29) then begin m:=5; end else
if (no >=30) and (no<=59) then begin no:=no-29;m:=6; end else
if (no >=60) and (no<=88) then begin no:=no-59;m:=7; end else
if (no >=89) and (no<=118) then begin no:=no-88;m:=8; end else
if (no >=119) and (no<=148) then begin no:=no-118;m:=88;end else
if (no >=149) and (no<=177) then begin no:=no-148;m:=9; end else
if (no >=178) and (no<=207) then begin no:=no-177;m:=10;end else
if (no >=208) and (no<=236) then begin no:=no-207;m:=11;end else
if (no >=237) and (no<=266) then begin no:=no-236;m:=12;end else
if (no >=267) and (no<=295) then begin no:=no-266;m:=1; nthaiyear:=nthaiyear+1; end;
end else
if _index=2 then
begin
if (no >=-117)and (no<=-89) then begin no:=no+118;m:=1; end else
if (no >=-88) and (no<=-59) then begin no:=no+89;m:=2; end else
if (no >=-58) and (no<=-30) then begin no:=no+59;m:=3; end else
if (no >=-29) and (no<=0) then begin no:=no+30;m:=4; end else
if (no >=1) and (no<=29) then begin m:=5; end else
if (no >=30) and (no<=59) then begin no:=no-29;m:=6; end else
if (no >=60) and (no<=89) then begin no:=no-59;m:=7; end else
if (no >=90) and (no<=119) then begin no:=no-88;m:=8; end else
if (no >=120) and (no<=148) then begin no:=no-119;m:=9; end else
if (no >=149) and (no<=178) then begin no:=no-148;m:=10;end else
if (no >=179) and (no<=207) then begin no:=no-178;m:=11;end else
if (no >=208) and (no<=237) then begin no:=no-207;m:=12;end else
if (no >=238) and (no<=266) then begin no:=no-237;m:=1; nthaiyear:=nthaiyear+1; end else
if (no >=267) and (no<=296) then begin no:=no-266;m:=1; nthaiyear:=nthaiyear+1; end;
end else
begin
if (no >=-117)and (no<=-89) then begin no:=no+118;m:=1; end else
if (no >=-88) and (no<=-59) then begin no:=no+89;m:=2; end else
if (no >=-58) and (no<=-30) then begin no:=no+59;m:=3; end else
if (no >=-29) and (no<=0) then begin no:=no+30;m:=4; end else
if (no >=1) and (no<=29) then begin m:=5; end else
if (no >=30) and (no<=59) then begin no:=no-29;m:=6; end else
if (no >=60) and (no<=88) then begin no:=no-59;m:=7; end else
if (no >=89) and (no<=118) then begin no:=no-88;m:=8; end else
if (no >=119) and (no<=147) then begin no:=no-118;m:=9; end else
if (no >=148) and (no<=177) then begin no:=no-147;m:=10;end else
if (no >=178) and (no<=206) then begin no:=no-177;m:=11;end else
if (no >=207) and (no<=236) then begin no:=no-206;m:=12;end else
if (no >=237) and (no<=265) then begin no:=no-236;m:=1; nthaiyear:=nthaiyear+1; end else
if (no >=266) and (no<=295) then begin no:=no-265;m:=1; nthaiyear:=nthaiyear+1; end;
end;
สีเขียวเป็นแก้ไขอีกรอบครับนับจำนวนวันผิด