ScriptCore3.TryEncodeDate

From Soldat Community Wiki
Revision as of 10:11, 25 August 2013 by Mighty (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
function TryEncodeDate(Year, Month, Day: Word; var Date: TDateTime): Boolean;
 Year: Year to be encoded
 Month: Month to be encoded
 Day: Day to be encoded
 Date: Result of encoding
 Result: TRUE if encoding has been successfull

Description

This function is equivalent to EncodeDate, however, it allows to check whether encoding has been successfull or not.
Note that arguments are not decimal numbers.

Example

var
  y,m,d: Word;
  currdate: TDateTime;
begin
  // today (for me) it's 25th August 2013
  y := 2013;
  m := 8;
  d := 25;
  
  if TryEncodeDate(y,m,d,currdate) then
    WriteLn(FormatFloat('0',currdate));
    // 41511
end.