Sign in Join
FPDoc Onlineexperiment

WeeksInYear function

In unit DateUtils

Returns the number of weeks in the year, given a date.

Declaration

pascal
function WeeksInYear(const AValue: TDateTime): Word

Arguments

AValue

Day in the year.

Function result

Number of weeks.

Description

WeeksInYear returns the number of weeks in the year part of AValue. The return value is either 52 or 53.

The first week of the year is determined according to the ISO 8601 standard: It is the first week that has at least 4 days in it, i.e. it includes a Thursday.

See also

Example: ex12

pascal
Program Example12;

{ This program demonstrates the WeeksInYear function }

Uses SysUtils,DateUtils;

Var
  Y : Word;

Begin
  For Y:=1992 to 2010 do
    Writeln(Y,' has ',WeeksInYear(EncodeDate(Y,2,1)),' weeks.');
End.

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