سلام.
از اين بهتر پيدا نمي كنيد.
البته اينو كامبيز خجسته نوشته و من با مختصري تغييرات(فقط در اسمها) براتون ميذارم.
در این یونیت دارای توابع جالبیه مثل تشخیص اینکه یک سال شمسی یا میلادی کبیسه هست یا نه. یا مثلا" امروز چندمین روز ساله و...
اميد وارم تكراري نباشه.
مثال:
[align=left:f004170b1e]var
year,month,day:Word;
begin
year:=2005;
month:=2;
day:=3;
miladttoshamsi(year,month,day![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
ShowMessage(Format('1970/4/28 Milady = %d/%d/%d Shamsi', }
{ [Year, Month, Day]))
// 1383/11/15
**********************************************************************
[align=left]{------------------------------------------------------------------------------}
{ }
{ ShamsiUtl - Shamsi Date Utility Functions }
{ Copyright(C) 1995-2003 Kambiz R. Khojasteh, all rights reserved. }
{ }
{ [email protected] }
{ http://www.delphiarea.com }
{ }
{ This unit is provided "AS IS" without any warranty of any kind, either }
{ express or implied. The entire risk as to the quality and performance }
{ of the functions provided in this unit are with you. The author is NOT }
{ liable for any DAMAGES resulting from the use and misuse of the unit, }
{ especially he is NOT liable for DAMAGES that were caused BY ANY VERSION }
{ WHICH HAS NOT BEEN PROGRAMMED BY THE AUTHOR HIMSELF. }
{ }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ F U N C T I O N R E F E R E N C E }
{------------------------------------------------------------------------------}
{ }
{ TDateKind = (dkShamsi, dkMilady); }
{ }
{ This data type is the type of the first parameter of those functions, }
{ which can work on both of Shamsi and Milady dates to identify the }
{ desire calender system. }
{ }
{------------------------------------------------------------------------------}
{ }
{ function IsLeapYear(DateKind: TDateKind; Year: Word): Boolean; }
{ }
{ Returns true when the specified Year is a leap year (Kabiseh). }
{ }
{ Example: }
{ }
{ if IsLeapYear(dkShamsi, 1375) then }
{ ShowMessage('1375 is leap year'); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function DaysOfMonth(DateKind: TDateKind; Year, Month: Word): Word; }
{ }
{ Returns the number of days in the specified month. If the given date }
{ is not valid, it returns zero. }
{ }
{ Example: }
{ }
{ if DaysOfMonth(dkShamsi, 1375, 12) = 30 then }
{ ShowMessage('Esfand 1375 has 30 days, so it is leap year'); }
{ }
{------------------------------------------------------------------------------}
{ }
{ fnction IsDateValid(DateKind: TDateKind; Year, Month, Day: Word): Boolean; }
{ }
{ Returns true if the specified date is a valid date. }
{ }
{ Example: }
{ }
{ if IsDateValid((dkShamsi, 1375, 12, 30) then }
{ ShowMessage('30 Esfand 1375 is valid, so it is leap year'); }
{ }
{------------------------------------------------------------------------------}
{ }
{ DaysToDate(DateKind: TDateKind; Year, Month, Day: Word): Word; }
{ }
{ Returns the number of days since the first day of the year until the }
{ specified date. If the given date is not valid, it returns zero. }
{ }
{ Example: }
{ }
{ ShowMessage(Format('1349/2/8 is the %dth day of 1349', }
{ [DaysToDate(dkShamsi, 1349, 2, 8)])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function DateOfDay(DateKind: TDateKind; Days, Year: Word; }
{ var Month, Day: Word): Boolean; }
{ }
{ }
{ Gives the number of days since the first day of the specified year and }
{ sets the Month and Day parameter to the proper values. If the date is a }
{ valid date, the function returns true, otherwise false will be returned. }
{ }
{ Example: }
{ }
{ DateOfDay(dkShamsi, 39, 1349, Month, Day); }
{ ShowMessage(Format('39th day of 1349 is 1349/%d/%d', [Month, Day])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function MiladyToShamsi(var Year, Month, Day: Word): Boolean; }
{ }
{ Converts the passed components of the Milady date to the appropriate }
{ Shamsi values. In case of any error, it returns false. }
{ }
{ Example: }
{ }
{ Year := 1970; }
{ Month := 4; }
{ Day := 28; }
{ MiladyToShamsi(Year, Month, Day); }
{ ShowMessage(Format('1970/4/28 Milady = %d/%d/%d Shamsi', }
{ [Year, Month, Day])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function ShamsiToMilady(var Year, Month, Day: Word): Boolean; }
{ }
{ Converts the passed components of the Shamsi date to the appropriate }
{ Milady values. In case of any error, it returns false. }
{ }
{ Example: }
{ }
{ Year := 1349; }
{ Month := 2; }
{ Day := 8; }
{ MiladyToShamsi(Year, Month, Day); }
{ ShowMessage(Format('1349/2/8 Shamsi = %d/%d/%d Milady', }
{ [Year, Month, Day])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function ShamsiEncodeDate(Year, Month, Day: Word): TDateTime; }
{ }
{ Returns a TDateTime type as Milady for a specified Year, Month, and }
{ Day as Shamsi. If the specified Shamsi date does not indicate a valid date, }
{ the return value is zero. }
{ }
{ Example: }
{ }
{ ShowMessage(DateToStr(ShamsiEncodeDate(1349, 2, 8))); }
{ }
{------------------------------------------------------------------------------}
{ }
{ procedure ShamsiDecodeDate(Date: TDateTime; var Year, Month, Day: Word); }
{ }
{ Breaks the passed Date as Milady into the appropriate Year, Month, and }
{ Day values as Shamsi. }
{ }
{ Example: }
{ }
{ ShamsiDecodeDate(Date, Year, Month, Day); }
{ ShowMessage(Format('Today is %d/%d/%d', [Year, Month, Day])); }
{ }
{------------------------------------------------------------------------------}
unit UShamsiDate;
interface
type
TDateKind = (dkShamsi, dkMilady);
function IsLeapYear(DateKind: TDateKind; Year: Word): Boolean;
function DaysOfMonth(DateKind: TDateKind; Year, Month: Word): Word;
function IsDateValid(DateKind: TDateKind; Year, Month, Day: Word): Boolean;
function DaysToDate(DateKind: TDateKind; Year, Month, Day: Word): Word;
function DateOfDay(DateKind: TDateKind; Days, Year: Word; var Month, Day: Word): Boolean;
function MiladyToShamsi(var Year, Month, Day: Word): Boolean;
function ShamsiToMilady(var Year, Month, Day: Word): Boolean;
function ShamsiEncodeDate(Year, Month, Day: Word): TDateTime;
procedure ShamsiDecodeDate(Date: TDateTime; var Year, Month, Day: Word);
implementation
uses
SysUtils, UReview;
const
LeapMonth: array[TDateKind] of Byte =
(12 {Esfand}, 2 {February});
DaysOfMonths: array[TDateKind, 1..12] of Byte = (
( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 )
{ Far, Ord, Kho, Tir, Mor, Sha, Meh, Aba, Aza, Day, Bah,^Esf },
( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
{ Jan,^Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec });
DaysToMonth: array[TDateKind, 1..13] of Word = (
( 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365 )
{ Far, Ord, Kho, Tir, Mor, Sha, Meh, Aba, Aza, Day, Bah,^Esf, *** },
( 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 )
{ Jan,^Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, *** });
//--------------------------------------------------------------
function IsLeapYear(DateKind: TDateKind; Year: Word): Boolean;
begin
if DateKind = dkShamsi then
Result := ((((LongInt(Year) + 38) * 31) mod 128) <= 30)
else
Result := ((Year mod 4) = 0) and (((Year mod 100) <> 0) or ((Year mod 400) = 0));
end;
//---------------------------------------------------------------
function DaysOfMonth(DateKind: TDateKind; Year, Month: Word): Word;
begin
if (Year <> 0) and (Month in [1..12]) then
begin
Result := DaysOfMonths[DateKind, Month];
if (Month = LeapMonth[DateKind]) and IsLeapYear(DateKind, Year) then
Inc(Result);
end
else
Result := 0;
end;
//---------------------------------------------------------------
function IsDateValid(DateKind: TDateKind; Year, Month, Day: Word): Boolean;
begin
Result := (Year <> 0) and (Month >= 1) and (Month <= 12) and
(Day >= 1) and (Day <= DaysOfMonth(DateKind, Year, Month));
end;
//---------------------------------------------------------------
function DaysToDate(DateKind: TDateKind; Year, Month, Day: Word): Word;
begin
if IsDateValid(DateKind, Year, Month, Day) then
begin
Result := DaysToMonth[DateKind, Month] + Day;
if (Month > LeapMonth[DateKind]) and IsLeapYear(DateKind, Year) then
Inc(Result);
end
else
Result := 0;
end;
//---------------------------------------------------------------
function DateOfDay(DateKind: TDateKind; Days, Year: Word; var Month, Day: Word): Boolean;
var
LeapDay, m: Integer;
begin
LeapDay := 0;
Month := 0;
Day := 0;
for m := 2 to 13 do
begin
if (m > LeapMonth[DateKind]) and IsLeapYear(DateKind, Year) then
LeapDay := 1;
if Days <= (DaysToMonth[DateKind, m] + LeapDay) then
begin
Month := m - 1;
if Month <= LeapMonth[DateKind] then LeapDay := 0;
Day := Days - (DaysToMonth[DateKind, Month] + LeapDay);
Break;
end;
end;
Result := IsDateValid(DateKind, Year, Month, Day);
end;
//---------------------------------------------------------------
function MiladyToShamsi(var Year, Month, Day: Word): Boolean;
var
LeapDay, Days: Integer;
PrevMiladyLeap: Boolean;
begin
if IsDateValid(dkMilady, Year, Month, Day) then
begin
PrevMiladyLeap := IsLeapYear(dkMilady, Year-1);
Days := DaysToDate(dkMilady, Year, Month, Day);
Dec(Year, 622);
if IsLeapYear(dkShamsi, Year) then
LeapDay := 1
else
LeapDay := 0;
if PrevMiladyLeap and (LeapDay = 1) then
Inc(Days, 287)
else
Inc(Days, 286);
if Days > (365 + LeapDay) then
begin
Inc(Year);
Dec(Days, 365 + LeapDay);
end;
Result := DateOfDay(dkShamsi, Days, Year, Month, Day);
end
else
Result := False;
end;
//---------------------------------------------------------------
function ShamsiToMilady(var Year, Month, Day: Word): Boolean;
var
LeapDay, Days: Integer;
PrevShamsiLeap: Boolean;
begin
if IsDateValid(dkShamsi, Year, Month, Day) then
begin
PrevShamsiLeap := IsLeapYear(dkShamsi, Year-1);
Days := DaysToDate(dkShamsi, Year, Month, Day);
Inc(Year, 621);
if IsLeapYear(dkMilady, Year) then
LeapDay := 1
else
LeapDay := 0;
if PrevShamsiLeap and (LeapDay = 1) then
Inc(Days, 80)
else
Inc(Days, 79);
if Days > (365 + LeapDay) then
begin
Inc(Year);
Dec(Days, 365 + LeapDay);
end;
Result := DateOfDay(dkMilady, Days, Year, Month, Day);
end
else
Result := False;
end;
//---------------------------------------------------------------
function ShamsiEncodeDate(Year, Month, Day: Word): TDateTime;
begin
if ShamsiToMilady(Year, Month, Day) then
Result := EncodeDate(Year, Month, Day)
else
Result := 0;
end;
//---------------------------------------------------------------
procedure ShamsiDecodeDate(Date: TDateTime; var Year, Month, Day: Word);
begin
DecodeDate(Date, Year, Month, Day);
MiladyToShamsi(Year, Month, Day);
end;
end.
[/align:f004170b1e]
از اين بهتر پيدا نمي كنيد.
البته اينو كامبيز خجسته نوشته و من با مختصري تغييرات(فقط در اسمها) براتون ميذارم.
در این یونیت دارای توابع جالبیه مثل تشخیص اینکه یک سال شمسی یا میلادی کبیسه هست یا نه. یا مثلا" امروز چندمین روز ساله و...
اميد وارم تكراري نباشه.
مثال:
[align=left:f004170b1e]var
year,month,day:Word;
begin
year:=2005;
month:=2;
day:=3;
miladttoshamsi(year,month,day
ShowMessage(Format('1970/4/28 Milady = %d/%d/%d Shamsi', }
{ [Year, Month, Day]))
// 1383/11/15
**********************************************************************
[align=left]{------------------------------------------------------------------------------}
{ }
{ ShamsiUtl - Shamsi Date Utility Functions }
{ Copyright(C) 1995-2003 Kambiz R. Khojasteh, all rights reserved. }
{ }
{ [email protected] }
{ http://www.delphiarea.com }
{ }
{ This unit is provided "AS IS" without any warranty of any kind, either }
{ express or implied. The entire risk as to the quality and performance }
{ of the functions provided in this unit are with you. The author is NOT }
{ liable for any DAMAGES resulting from the use and misuse of the unit, }
{ especially he is NOT liable for DAMAGES that were caused BY ANY VERSION }
{ WHICH HAS NOT BEEN PROGRAMMED BY THE AUTHOR HIMSELF. }
{ }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ F U N C T I O N R E F E R E N C E }
{------------------------------------------------------------------------------}
{ }
{ TDateKind = (dkShamsi, dkMilady); }
{ }
{ This data type is the type of the first parameter of those functions, }
{ which can work on both of Shamsi and Milady dates to identify the }
{ desire calender system. }
{ }
{------------------------------------------------------------------------------}
{ }
{ function IsLeapYear(DateKind: TDateKind; Year: Word): Boolean; }
{ }
{ Returns true when the specified Year is a leap year (Kabiseh). }
{ }
{ Example: }
{ }
{ if IsLeapYear(dkShamsi, 1375) then }
{ ShowMessage('1375 is leap year'); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function DaysOfMonth(DateKind: TDateKind; Year, Month: Word): Word; }
{ }
{ Returns the number of days in the specified month. If the given date }
{ is not valid, it returns zero. }
{ }
{ Example: }
{ }
{ if DaysOfMonth(dkShamsi, 1375, 12) = 30 then }
{ ShowMessage('Esfand 1375 has 30 days, so it is leap year'); }
{ }
{------------------------------------------------------------------------------}
{ }
{ fnction IsDateValid(DateKind: TDateKind; Year, Month, Day: Word): Boolean; }
{ }
{ Returns true if the specified date is a valid date. }
{ }
{ Example: }
{ }
{ if IsDateValid((dkShamsi, 1375, 12, 30) then }
{ ShowMessage('30 Esfand 1375 is valid, so it is leap year'); }
{ }
{------------------------------------------------------------------------------}
{ }
{ DaysToDate(DateKind: TDateKind; Year, Month, Day: Word): Word; }
{ }
{ Returns the number of days since the first day of the year until the }
{ specified date. If the given date is not valid, it returns zero. }
{ }
{ Example: }
{ }
{ ShowMessage(Format('1349/2/8 is the %dth day of 1349', }
{ [DaysToDate(dkShamsi, 1349, 2, 8)])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function DateOfDay(DateKind: TDateKind; Days, Year: Word; }
{ var Month, Day: Word): Boolean; }
{ }
{ }
{ Gives the number of days since the first day of the specified year and }
{ sets the Month and Day parameter to the proper values. If the date is a }
{ valid date, the function returns true, otherwise false will be returned. }
{ }
{ Example: }
{ }
{ DateOfDay(dkShamsi, 39, 1349, Month, Day); }
{ ShowMessage(Format('39th day of 1349 is 1349/%d/%d', [Month, Day])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function MiladyToShamsi(var Year, Month, Day: Word): Boolean; }
{ }
{ Converts the passed components of the Milady date to the appropriate }
{ Shamsi values. In case of any error, it returns false. }
{ }
{ Example: }
{ }
{ Year := 1970; }
{ Month := 4; }
{ Day := 28; }
{ MiladyToShamsi(Year, Month, Day); }
{ ShowMessage(Format('1970/4/28 Milady = %d/%d/%d Shamsi', }
{ [Year, Month, Day])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function ShamsiToMilady(var Year, Month, Day: Word): Boolean; }
{ }
{ Converts the passed components of the Shamsi date to the appropriate }
{ Milady values. In case of any error, it returns false. }
{ }
{ Example: }
{ }
{ Year := 1349; }
{ Month := 2; }
{ Day := 8; }
{ MiladyToShamsi(Year, Month, Day); }
{ ShowMessage(Format('1349/2/8 Shamsi = %d/%d/%d Milady', }
{ [Year, Month, Day])); }
{ }
{------------------------------------------------------------------------------}
{ }
{ function ShamsiEncodeDate(Year, Month, Day: Word): TDateTime; }
{ }
{ Returns a TDateTime type as Milady for a specified Year, Month, and }
{ Day as Shamsi. If the specified Shamsi date does not indicate a valid date, }
{ the return value is zero. }
{ }
{ Example: }
{ }
{ ShowMessage(DateToStr(ShamsiEncodeDate(1349, 2, 8))); }
{ }
{------------------------------------------------------------------------------}
{ }
{ procedure ShamsiDecodeDate(Date: TDateTime; var Year, Month, Day: Word); }
{ }
{ Breaks the passed Date as Milady into the appropriate Year, Month, and }
{ Day values as Shamsi. }
{ }
{ Example: }
{ }
{ ShamsiDecodeDate(Date, Year, Month, Day); }
{ ShowMessage(Format('Today is %d/%d/%d', [Year, Month, Day])); }
{ }
{------------------------------------------------------------------------------}
unit UShamsiDate;
interface
type
TDateKind = (dkShamsi, dkMilady);
function IsLeapYear(DateKind: TDateKind; Year: Word): Boolean;
function DaysOfMonth(DateKind: TDateKind; Year, Month: Word): Word;
function IsDateValid(DateKind: TDateKind; Year, Month, Day: Word): Boolean;
function DaysToDate(DateKind: TDateKind; Year, Month, Day: Word): Word;
function DateOfDay(DateKind: TDateKind; Days, Year: Word; var Month, Day: Word): Boolean;
function MiladyToShamsi(var Year, Month, Day: Word): Boolean;
function ShamsiToMilady(var Year, Month, Day: Word): Boolean;
function ShamsiEncodeDate(Year, Month, Day: Word): TDateTime;
procedure ShamsiDecodeDate(Date: TDateTime; var Year, Month, Day: Word);
implementation
uses
SysUtils, UReview;
const
LeapMonth: array[TDateKind] of Byte =
(12 {Esfand}, 2 {February});
DaysOfMonths: array[TDateKind, 1..12] of Byte = (
( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 )
{ Far, Ord, Kho, Tir, Mor, Sha, Meh, Aba, Aza, Day, Bah,^Esf },
( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
{ Jan,^Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec });
DaysToMonth: array[TDateKind, 1..13] of Word = (
( 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365 )
{ Far, Ord, Kho, Tir, Mor, Sha, Meh, Aba, Aza, Day, Bah,^Esf, *** },
( 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 )
{ Jan,^Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, *** });
//--------------------------------------------------------------
function IsLeapYear(DateKind: TDateKind; Year: Word): Boolean;
begin
if DateKind = dkShamsi then
Result := ((((LongInt(Year) + 38) * 31) mod 128) <= 30)
else
Result := ((Year mod 4) = 0) and (((Year mod 100) <> 0) or ((Year mod 400) = 0));
end;
//---------------------------------------------------------------
function DaysOfMonth(DateKind: TDateKind; Year, Month: Word): Word;
begin
if (Year <> 0) and (Month in [1..12]) then
begin
Result := DaysOfMonths[DateKind, Month];
if (Month = LeapMonth[DateKind]) and IsLeapYear(DateKind, Year) then
Inc(Result);
end
else
Result := 0;
end;
//---------------------------------------------------------------
function IsDateValid(DateKind: TDateKind; Year, Month, Day: Word): Boolean;
begin
Result := (Year <> 0) and (Month >= 1) and (Month <= 12) and
(Day >= 1) and (Day <= DaysOfMonth(DateKind, Year, Month));
end;
//---------------------------------------------------------------
function DaysToDate(DateKind: TDateKind; Year, Month, Day: Word): Word;
begin
if IsDateValid(DateKind, Year, Month, Day) then
begin
Result := DaysToMonth[DateKind, Month] + Day;
if (Month > LeapMonth[DateKind]) and IsLeapYear(DateKind, Year) then
Inc(Result);
end
else
Result := 0;
end;
//---------------------------------------------------------------
function DateOfDay(DateKind: TDateKind; Days, Year: Word; var Month, Day: Word): Boolean;
var
LeapDay, m: Integer;
begin
LeapDay := 0;
Month := 0;
Day := 0;
for m := 2 to 13 do
begin
if (m > LeapMonth[DateKind]) and IsLeapYear(DateKind, Year) then
LeapDay := 1;
if Days <= (DaysToMonth[DateKind, m] + LeapDay) then
begin
Month := m - 1;
if Month <= LeapMonth[DateKind] then LeapDay := 0;
Day := Days - (DaysToMonth[DateKind, Month] + LeapDay);
Break;
end;
end;
Result := IsDateValid(DateKind, Year, Month, Day);
end;
//---------------------------------------------------------------
function MiladyToShamsi(var Year, Month, Day: Word): Boolean;
var
LeapDay, Days: Integer;
PrevMiladyLeap: Boolean;
begin
if IsDateValid(dkMilady, Year, Month, Day) then
begin
PrevMiladyLeap := IsLeapYear(dkMilady, Year-1);
Days := DaysToDate(dkMilady, Year, Month, Day);
Dec(Year, 622);
if IsLeapYear(dkShamsi, Year) then
LeapDay := 1
else
LeapDay := 0;
if PrevMiladyLeap and (LeapDay = 1) then
Inc(Days, 287)
else
Inc(Days, 286);
if Days > (365 + LeapDay) then
begin
Inc(Year);
Dec(Days, 365 + LeapDay);
end;
Result := DateOfDay(dkShamsi, Days, Year, Month, Day);
end
else
Result := False;
end;
//---------------------------------------------------------------
function ShamsiToMilady(var Year, Month, Day: Word): Boolean;
var
LeapDay, Days: Integer;
PrevShamsiLeap: Boolean;
begin
if IsDateValid(dkShamsi, Year, Month, Day) then
begin
PrevShamsiLeap := IsLeapYear(dkShamsi, Year-1);
Days := DaysToDate(dkShamsi, Year, Month, Day);
Inc(Year, 621);
if IsLeapYear(dkMilady, Year) then
LeapDay := 1
else
LeapDay := 0;
if PrevShamsiLeap and (LeapDay = 1) then
Inc(Days, 80)
else
Inc(Days, 79);
if Days > (365 + LeapDay) then
begin
Inc(Year);
Dec(Days, 365 + LeapDay);
end;
Result := DateOfDay(dkMilady, Days, Year, Month, Day);
end
else
Result := False;
end;
//---------------------------------------------------------------
function ShamsiEncodeDate(Year, Month, Day: Word): TDateTime;
begin
if ShamsiToMilady(Year, Month, Day) then
Result := EncodeDate(Year, Month, Day)
else
Result := 0;
end;
//---------------------------------------------------------------
procedure ShamsiDecodeDate(Date: TDateTime; var Year, Month, Day: Word);
begin
DecodeDate(Date, Year, Month, Day);
MiladyToShamsi(Year, Month, Day);
end;
end.
[/align:f004170b1e]