ScriptCore3.EncodeTime

From Soldat Community Wiki
Revision as of 00:18, 21 June 2018 by Savage0795 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;
 Hour: Hours to be encoded
 Min: Minutes to be encoded
 Sec: Seconds to be encoded
 MSec: Miliseconds to be encoded
 Result: TDateTime depending on provided arguments

Description

This function allows to convert given Hour, Min, Sec and MSec into a TDateTime format.
Note that arguments are not decimal numbers.

Example

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

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

//How to encode by yourself
  WriteLn(FloatToStr(EncodeTime(3, 0, 0, 0)));//0.125000000000
  WriteLn(FloatToStr(1.0/24*3));//0.125000000000

  WriteLn(FloatToStr(EncodeTime(0, 27, 0, 0)));//0.018750000000
  WriteLn(FloatToStr(1.0/1440*27));//0.018750000000
//1.0/24 - 1 hour
//1.0/1440 - 1 minute
//1.0/86400 - 1 second
//1.0/86400000 - 1 millisecond
end.