ScriptCore3.TryEncodeTime

From Soldat Community Wiki
Jump to: navigation, search
function TryEncodeTime(Hour, Min, Sec, MSec: Word; var Date: TDateTime): Boolean;
 Hour: Hours to be encoded
 Min: Minutes to be encoded
 Sec: Seconds to be encoded
 MSec: Miliseconds to be encoded
 Date: Encoding result
 Result: whether conversion has been successfull;

Description

This function is equivalent to EncodeTime, however, it allows to check whether encoding has been successfull.

Example

var
  h,m,s: Word;
  currtime: TDateTime;
begin
  // it's 10:57:24 at the moment.

  h := 10;
  m := 57;
  s := 24;
  
  if TryEncodeTime(h,m,s,0,currtime) then
    WriteLn(FormatFloat('0.#########',currtime));
    // 0.456527778
end.