برای تبدیل تاریخ میلادی به شمسی میتوانید از تابع زیر استفاده کنید.
function changedate():string;
const
shamsi:array[0..11] of Integer=(0,31,62,93,124,155,186,216,246,276,306,336);
miladi:array[0..11] of integer=(0,31,59,90,120,151,181,212,243,273,304,334);
miladicab:array[0..11] of integer=(0,31,60,91,121,152,182,213,244,274,305,335);
var
cabise:array[0..19] of integer;
ezafe,baghi,res,i,sals,salm,mahm,mahs,roozm,roozs,majrooz:integer;
boolcabisemi,boolcabisesh:boolean;
s,s1,s2:string;
begin
cabise[0]:=2000;
cabise[1]:=2004;
cabise[2]:=2008;
S:=DateToStr(date);
while Pos('/', S) > 0 do
S[Pos('/', S)] := '0';
salm:=(StrToInt64(s) div 1000000);
baghi:=strtoint64(s) mod 100000;
mahm:=baghi div 1000;
roozm:=(baghi mod 100);
ezafe:=0;
boolcabisemi:=false;
boolcabisesh:=false;
for i:=0 to 19 do
if salm=cabise[i] then
begin
boolcabisemi:=true;
break;
end;
if boolcabisemi then
begin
majrooz:=miladicab[mahm-1]+roozm;
res:=80-majrooz;
if res<=0 then
res:=-(res)
else res:=365-res;
for i:=11 downto 0 do
if res>=shamsi[i] then
begin
mahs:=i+1;
roozs:=res-shamsi[i];
break;
end;
end
else
begin
majrooz:=miladi[mahm-1]+roozm;
res:=80-majr ooz
if res<=0 then
res:=-(res)
else res:=365-res;
for i:=11 downto 0 do
if res>=shamsi[i] then
begin
mahs:=i+1;
roozs:=res-shamsi[i];
Break;
end;
end;
if 80-majrooz>=1 then
sals:=salm-622
else
sals:=salm-621;
i:=sals-1383;
if (i mod 4)=0 then
boolcabisesh:=true;
if (boolcabisemi) and (boolcabisesh) then
ezafe:=0
else
ezafe:=1;
if (boolcabisesh) then
ezafe:=ezafe+1;
if (boolcabisesh) and not(boolcabisemi) then
if roozs=29 then
begin
roozs:=-1;
mahs:=mahs+1;
end;
roozs:=roozs+ezafe;
if roozs<10 then
s1:='0'+IntToStr(roozs)
else
s1:=IntToStr(roozs);
if mahs<10 then
s2:='0'+IntToStr(mahs)
else
s2:=IntToStr(mahs);
s:=IntToStr(sals)+'/'+s2+'/'+s1;
changedate:=s;
end;