mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-25 13:49:29 +02:00
* Fix bug ID #25177: wrong constant used for rounding
git-svn-id: trunk@34507 -
This commit is contained in:
parent
8c63be40f9
commit
63d3df5642
@ -442,6 +442,8 @@ uses sysconst;
|
||||
|
||||
const
|
||||
TDateTimeEpsilon = 2.2204460493e-16;
|
||||
HalfMilliSecond = OneMillisecond /2 ;
|
||||
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Auxiliary routines
|
||||
@ -1281,49 +1283,49 @@ end;
|
||||
|
||||
Function YearsBetween(const ANow, AThen: TDateTime): Integer;
|
||||
begin
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon)/ApproxDaysPerYear);
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)/ApproxDaysPerYear);
|
||||
end;
|
||||
|
||||
|
||||
Function MonthsBetween(const ANow, AThen: TDateTime): Integer;
|
||||
begin
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon)/ApproxDaysPerMonth);
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)/ApproxDaysPerMonth);
|
||||
end;
|
||||
|
||||
|
||||
Function WeeksBetween(const ANow, AThen: TDateTime): Integer;
|
||||
begin
|
||||
Result:=Trunc(Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon) div 7;
|
||||
Result:=Trunc(Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond) div 7;
|
||||
end;
|
||||
|
||||
|
||||
Function DaysBetween(const ANow, AThen: TDateTime): Integer;
|
||||
begin
|
||||
Result:=Trunc(Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon);
|
||||
Result:=Trunc(Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond);
|
||||
end;
|
||||
|
||||
|
||||
Function HoursBetween(const ANow, AThen: TDateTime): Int64;
|
||||
begin
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon)*HoursPerDay);
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)*HoursPerDay);
|
||||
end;
|
||||
|
||||
|
||||
Function MinutesBetween(const ANow, AThen: TDateTime): Int64;
|
||||
begin
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon)*MinsPerDay);
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)*MinsPerDay);
|
||||
end;
|
||||
|
||||
|
||||
Function SecondsBetween(const ANow, AThen: TDateTime): Int64;
|
||||
begin
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon)*SecsPerDay);
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)*SecsPerDay);
|
||||
end;
|
||||
|
||||
|
||||
Function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;
|
||||
begin
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+TDateTimeEpsilon)*MSecsPerDay);
|
||||
Result:=Trunc((Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)*MSecsPerDay);
|
||||
end;
|
||||
|
||||
Procedure PeriodBetween(Const ANow, AThen: TDateTime; Out Years, months, days : Word);
|
||||
|
Loading…
Reference in New Issue
Block a user