DecodeDateWeek reverse engineers a date AValue, and returns the date broken into its various component parts.

The parameters AYear, AWeekOfYear, and ADayOfWeek are populated with the parts of the date, so that you can then use the variables in your calculations.

This is the opposite of EncodeDateWeek EncodeDateWeek.

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

  • AYear returns the year that AValue represents.

  • AWeekOfYear returns the week within AYear that AValue represents, where 1 is the first week with four or more days.

  • ADayOfWeek returns the day within AWeekOfYear that AValue represents, where 1 is Monday and 7 is Sunday.

Declaration: procedure DecodeDateWeek(const AValue: TDateTime; out AYear, AWeekOfYear, ADayOfWeek: Word);

Such as the example below.

procedure OnMapEvent(var Value:Variant);
var
aYear, aWeek, aDay : word;
begin
//Break date/time into its individual parts
DecodeDateWeek(Now, aYear, aWeek, aDay);
 
if ((aWeek=3) and (aDay=7)) then
 
...do something at this special time...;
 
end;