محمد دادودنیا
پنج شنبه 25 آبان 1385, 00:59 صبح
Function MiladyToShamsi;
var
ny,nd,nm,dd:integer;
begin
ny:=0;
nd:=0;
nm:=0;
dd:=0;
ny:=y-621;
if m<3 then ny:=ny-1;
if (m=3) and (d<=20) then ny:=ny-1;
dd:=0;
if m=1 then dd:=d;
if m=2 then dd:=31+d;
if m=3 then dd:=31+28+d;
if m=4 then dd:=31+28+31+d;
if m=5 then dd:=31+28+31+30+d;
if m=6 then dd:=31+28+31+30+31+d;
if m=7 then dd:=31+28+31+30+31+30+d;
if m=8 then dd:=31+28+31+30+31+30+31+d;
if m=9 then dd:=31+28+31+30+31+30+31+31+d;
if m=10 then dd:=31+28+31+30+31+30+31+31+30+d;
if m=11 then dd:=31+28+31+30+31+30+31+31+30+31+d;
if m=12 then dd:=31+28+31+30+31+30+31+31+30+31+30+d;
if m<3 then dd:=dd+(366-80);
if m>3 then dd:=dd-79;
if (m=3) and (d<=20) then dd:=dd+(366-80);
if (m=3) and (d>20) then dd:=dd-79;
if (dd>=1) and (dd<=(6*31)) then
begin
nm:=(dd div 31);
nd:=(dd-(nm*31));
IF nd=0 Then nd:=31;
IF (nm<6) And (nd<>31) Then nm:=nm+1;
end
Else
if dd>186 then
begin
dd:=dd-186;
nm:=7+dd div 30;
nd:=dd mod 30;
if nd=0 then
begin
nd:=30;
nm:=nm-1;
end;
end;
d:=nd;
y:=ny;
m:=nm;
Result:=inttostr(y)+DelChar+AddZeroToFirst(inttost r(m),2)+DelChar+AddZeroToFirst(inttostr(d),2);
End;
var
ny,nd,nm,dd:integer;
begin
ny:=0;
nd:=0;
nm:=0;
dd:=0;
ny:=y-621;
if m<3 then ny:=ny-1;
if (m=3) and (d<=20) then ny:=ny-1;
dd:=0;
if m=1 then dd:=d;
if m=2 then dd:=31+d;
if m=3 then dd:=31+28+d;
if m=4 then dd:=31+28+31+d;
if m=5 then dd:=31+28+31+30+d;
if m=6 then dd:=31+28+31+30+31+d;
if m=7 then dd:=31+28+31+30+31+30+d;
if m=8 then dd:=31+28+31+30+31+30+31+d;
if m=9 then dd:=31+28+31+30+31+30+31+31+d;
if m=10 then dd:=31+28+31+30+31+30+31+31+30+d;
if m=11 then dd:=31+28+31+30+31+30+31+31+30+31+d;
if m=12 then dd:=31+28+31+30+31+30+31+31+30+31+30+d;
if m<3 then dd:=dd+(366-80);
if m>3 then dd:=dd-79;
if (m=3) and (d<=20) then dd:=dd+(366-80);
if (m=3) and (d>20) then dd:=dd-79;
if (dd>=1) and (dd<=(6*31)) then
begin
nm:=(dd div 31);
nd:=(dd-(nm*31));
IF nd=0 Then nd:=31;
IF (nm<6) And (nd<>31) Then nm:=nm+1;
end
Else
if dd>186 then
begin
dd:=dd-186;
nm:=7+dd div 30;
nd:=dd mod 30;
if nd=0 then
begin
nd:=30;
nm:=nm-1;
end;
end;
d:=nd;
y:=ny;
m:=nm;
Result:=inttostr(y)+DelChar+AddZeroToFirst(inttost r(m),2)+DelChar+AddZeroToFirst(inttostr(d),2);
End;