Sign in Join
FPDoc Onlineexperiment

TryEncodeDateDay function

In unit DateUtils

Encode a year and day of year to a TDateTime value.

Declaration

pascal
function TryEncodeDateDay(const AYear: Word; const ADayOfYear: Word; 
 out AValue: TDateTime): Boolean

Arguments

AYear

Year.

ADayOfYear

Day in the year.

AValue

Encoded TDateTime value.

Function result

True if the encoding was successful, False if not.

Description

TryEncodeDateDay encodes the values AYear and ADayOfYear to a date value and returns this value in AValue.

If the encoding was successful, True is returned. False is returned if any of the arguments is not valid.

See also

Example: ex84

pascal
Program Example84;

{ This program demonstrates the TryEncodeDateDay function }

Uses SysUtils,DateUtils;

Var
  Y,DoY : Word;
  TS : TDateTime;

Begin
  DecodeDateDay(Now,Y,DoY);
  If TryEncodeDateDay(Y,DoY,TS) then
    Writeln('Today is : ',DateToStr(TS))
  else
    Writeln('Wrong year/day of year indication');
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.