This is a defect in the documentation. The implementation of TryEncodeTime , which is what the actual work does, is as follows:
function TryEncodeTime(Hour, Min, Sec, MSec: Word; out Time: TDateTime): Boolean; var TS: TTimeStamp; begin Result := False; if (Hour < HoursPerDay) and (Min < MinsPerHour) and (Sec < SecsPerMin) and (MSec < MSecsPerSec) then begin .... Result := True; end; end;
Since HoursPerDay is 24 , it is clear that the implementation is not consistent with the documentation.
This is not even behavior that has changed over time. The TryEncodeTime method TryEncodeTime always behaved like this. For example, a similar function from Delphi 5 looks like this:
function DoEncodeTime(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean; begin Result := False; if (Hour < 24) and (Min < 60) and (Sec < 60) and (MSec < 1000) then begin Time := (Hour * 3600000 + Min * 60000 + Sec * 1000 + MSec) / MSecsPerDay; Result := True; end; end;
source share