see this thread:

http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-DateDif-function-needed-tt4034182.html#none

Is a function similiar to Jedi's DateDiff part of Freepascal now?

As i remember Michael van Canneyt wanted to implement that to Pascal 3.0??

That's Jedi's version:

procedure DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: word);
var
  DtSwap: TDateTime;
  Day1, Day2, Month1, Month2, Year1, Year2: word;
begin
  if Date1 > Date2 then
  begin
    DtSwap := Date1;
    Date1 := Date2;
    Date2 := DtSwap;
  end;
  DecodeDate(Date1, Year1, Month1, Day1);
  DecodeDate(Date2, Year2, Month2, Day2);
  Years := Year2 - Year1;
  Months := 0;
  Days := 0;
  if Month2 < Month1 then
  begin
    Inc(Months, 12);
    Dec(Years);
  end;
  Inc(Months, Month2 - Month1);
  if Day2 < Day1 then
  begin
    // von mir auskommentiert Inc(Days, DaysPerMonth(Year1, Month1));
    Inc(Days, DaysInAMonth(Year1, Month1));
    if Months = 0 then
    begin
      Dec(Years);
      Months := 11;
    end
    else
      Dec(Months);
  end;
  Inc(Days, Day2 - Day1);
end;
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to