EncodeDateWeek returns a TDateTime that represents a specified day ADayOfWeek, of a specified week AWeekOfYear, in a specified year AYear.

The time portion of the return value is 00:00:00 - midnight at the start of the specified day ADayOfWeek.

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

  • AYear is the year which can be any value from 1 through 9999 inclusive.

  • AWeekOfYear is the week within AYear, where 1 is the first week that includes four or more days.

    • 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 e.t.c.

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 will raise an error.

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

procedure OnMapEvent(var Value:Variant);
var
aYear, aWeek, aDay : word;
begin
aYear := 2024;
aWeek := 27;
aDay := 5;
//Create a date/time from its separate parts - returns 05-07-2024
LogInfo(FormatDateTime('dd-mm-yyyy hh:nn:ss.zzz',EncodeDateWeek(aYear, aWeek, aDay)));
LogInfo('');
 
end;