به اینجاش فکر نکرده بودم ولی با دستور زیر درست میشه و فرمت به هر صورتی باشه درست عمل میکنه :
کد:
کد:
strtemp:=FormatDateTime("yyyy/mm/dd", date1);
کد:
کد:
Function MiladiToShamsi(date1:TDate): String;
const
count_days : array[1..12] of Byte = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var
Year, Month, Day: Word ;
i: Byte;
st,strtemp: String;
day_year: Integer;
begin
strtemp:=FormatDateTime("yyyy/mm/dd", date1);
Year:=strtoint(copy(strtemp,1,4));
Month:=strtoint(copy(strtemp,6,2));
Day:=strtoint(copy(strtemp,9,2));
day_year:= 0;
for i:= 1 to month - 1 do
day_year:= day_year + count_days [ i ] ;
day_year:= day_year + day;
if IsLeapYear(Year) and (month > 2) then
Inc(day_year);
if (day_year <= 79) then
begin
if ((Year - 1) mod 4 = 0) then
day_year:= day_year + 11
else
day_year:= day_year + 10;
Year:= Year - 622;
if (day_year mod 30 = 0) then
begin
Month:= (day_year div 30) + 9;
Day:= 30;
end
else
begin
Month:= (day_year div 30) + 10;
Day:= day_year mod 30;
end;
end
else
begin
year:= year - 621;
day_year:= day_year - 79;
if (day_year <= 186) then
begin
if (day_year mod 31 = 0) then
begin
Month:= (day_year div 31);
Day:= 31;
end
else
begin
Month:= (day_year div 31) + 1;
Day:= day_year mod 31;
end;
end
else
begin
day_year:= day_year - 186;
if (day_year mod 30 = 0) then
begin
Month:= (day_year div 30) + 6;
Day:= 30;
end
else
begin
Month:= (day_year div 30) + 7;
Day:= day_year mod 30;
end;
end;
end; // else .
st:= IntToStr(Year) + "/";
if (Month < 10) then
st:= st + "0";
st:= st + IntToStr(Month) + "/";
if (Day < 10) then
st:= st + "0";
st:= st + IntToStr(Day);
Result:= st;
end;
علاقه مندي ها (Bookmarks)