Among other things, I’ve made a calendar. While working on the 2016 edition I thought it would be nice to have the week of the year on it. The Xojo date class provides a weekOfYear property, but it is not the ISO standard week of year. The ISO standard has the week start on Monday. It would be useful to add another property (e.g. isoWeek) to the date class.
Global Function WeekOfYearISO(Extends d As Xojo.Core.Date) As Integer
If d Is Nil Then Return -1
Dim isoDayOfWeek As Integer = d.DayOfWeek - 1
If isoDayOfWeek < 1 Then isoDayOfWeek = 7
// https://en.wikipedia.org/wiki/ISO_week_date#Calculation
Dim week As Integer
week = (d.DayOfYear - isoDayOfWeek + 10) / 7
Return week
End Function