From RAD Studio API Documentation
Jump to: navigation, search


function EncodeDateWeek(const AYear, AWeekOfYear, ADayOfWeek: Word): TDateTime;


extern DELPHI_PACKAGE System::TDateTime __fastcall EncodeDateWeek(const System::Word AYear, const System::Word AWeekOfYear, const System::Word ADayOfWeek = (System::Word)(0x1));


Type Visibility Source Unit Parent
function public
System.DateUtils System.DateUtils


Returns a TDateTime that represents a specified day of a specified week in a specified year.

EncodeDateWeek returns a TDateTime for the date specified by the AYear, AWeekOfYear, and ADayOfWeek parameters. The time portion of the return value is 0 (midnight at the start of the specified day).

AYear is the year. It can be any value from 1 through 9999 (inclusive).

AWeekOfYear is the week within that year, where 1 is the first week that includes four or more days. Note that if the first calendar day of the year is a Friday, Saturday, or Sunday, then those three days must be expressed using AYear set to the previous year and AWeekOfYear set to the number of weeks in the previous year. Similarly, if the last calendar day of the year is a Monday, Tuesday, or Wednesday, then those three days are expressed with AYear set to the following year and AWeekOfYear set to 1.

ADayOfWeek is the day of the week, where 1 is Monday, 2 is Tuesday, and so on.

Tip: To make the ADayOfWeek value more readable, use the day of week constants.

If AYear is not within range, AWeekOfYear is less than 1 or greater than the number of weeks in AYear, or ADayOfWeek is less than 1 or greater than 7, EncodeDateWeek raises an EConvertError exception.

Note: The definitions for AWeekOfYear and ADayOfWeek follow the ISO 8601 standard.

See Also

Code Examples