[Overview][Constants][Procedures and functions] Reference for unit 'dateutils' (#rtl)

TryEncodeDateWeek

Encode a year, week and day of week triplet to a TDateTimevalue

Declaration

Source position: line 0

function TryEncodeDateWeek(

  const AYear: Word;

  const AWeekOfYear: Word;

  var AValue: TDateTime;

  const ADayOfWeek: Word

):Boolean;

function TryEncodeDateWeek(

  const AYear: Word;

  const AWeekOfYear: Word;

  var AValue: TDateTime

):Boolean;

Arguments

AYear

  

Year

AWeekOfYear

  

Week in the year

AValue

  

Encoded TDateTimevalue

ADayOfWeek

  

Day of the week (default 1).

Function result

Trueif the encoding was succeful, Falseotherwise.

Arguments

AYear

  

Year

AWeekOfYear

  

Week in the year

AValue

  

Encoded TDateTimevalue

Function result

Trueif the encoding was succeful, Falseotherwise.

Description

TryEncodeDateWeekencodes the values AYear, AWeekOfYearand ADayOfWeekto a date value and returns this value in AValue.

If the encoding was succcesful, Trueis returned. Falseis returned if any of the arguments is not valid.

See also

EncodeDateMonthWeek

  

Encodes a year, month, week of month and day of week to a DateTime value

EncodeDateWeek

  

Encode a TDateTimevalue from a year, week and day of week triplet

EncodeDateTime

  

Encodes a DateTime value from all its parts

EncodeDateDay

  

Encodes a year and day of year to a DateTime value

TryEncodeDateTime

  

Encode a Year, Month, Day, Hour, minute, seconds, milliseconds tuplet to a TDateTimevalue

TryEncodeDateMonthWeek

  

Encode a year, month, week of month and day of week to a TDateTimevalue

TryEncodeDateDay

  

Encode a year and day of year to a TDateTimevalue

Example

Program Example82;

{ This program demonstrates the TryEncodeDateWeek function }

Uses SysUtils,DateUtils;

Var
  Y,W,Dow : Word;
  TS : TDateTime;

Begin
  DecodeDateWeek(Now,Y,W,Dow);
  If TryEncodeDateWeek(Y,W,TS,Dow) then
    Writeln('Today is : ',DateToStr(TS))
  else
    Writeln('Invalid date/week indication');
End.