Sometime users want to categorize documents in a view by calendar week.
The calculation of calendar week is differerent in different parts of the world, e.g. the rules for the US differ from the rules used in Europe.
The Notes client calculates the calendar week correctly, thus the necessary code must already be there and only needs to be made available.
Added bonus: also calculate the year of the calendar week, which can be different from the year of the date!
Example:
31st December 2018
US: Its the 53rd week of 2018
DE: Its the 1st week of 2019 (!)
This function could have three parameters:
- date (date; optional): date to calculate the calendar week for; default is the current date
- returnYear (boolean; optional): return the year of the calendar week; default is false (return week number)
- region (String or Integer; optional): region to calculate the calendar week for; default is the user's current region
Format(date, "ww") returns US calendar week, even when the user's region is Germany.
Example: January 3rd, 1999:
Messagebox Format(Datenumber(1999, 01, 03), "ww") => 2
In Germany this date - a Sunday - is the last day of calendar week 53 of 1998!