week
This function calculates the week number from the date. -1 is returned if the input parameter contains no recognizable date.
Indirect parameter passing is disabled
1-2
No. | Type | Description |
---|---|---|
1 input |
date or string converted to date | Date Value to check. |
Opt. 2 input |
numeral | Option 0: ISO week number, 1..52 or 53, all weeks are 7 days long. In some years, week 1 begins in the last days in December. In some other years, week 53 may run into early January. |
Type | Description |
---|---|
numeral | week number -1 is returned if no recognizable date is provided or wrong option value is used. |
d[1] = { 31.12.2020, 31.12.2021, 31.12.2022 }; // still a string. week() converts to date
d[2] = { 01.01.2020, 01.01.2021, 01.01.2022 };
for (option[] = 0, option[] <= 4, option[]++)
{
print( week( d[1]{0}, option[] ), " ", week( d[1]{1}, option[] ), " ", week( d[1]{2}, option[] ), " " );
echo ( week( d[2]{0}, option[] ), " ", week( d[2]{1}, option[] ), " ", week( d[2]{2}, option[] ) );
}
53 52 52 1 53 52
53 52 52 1 0 0
20.53 21.52 22.52 20.01 21 22
2020.53 2021.52 2022.52 2020.01 2021 2022
-1 -1 -1 -1 -1 -1