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.
you can extend the date class with a method and implement the right week count for you
the algorithms are certainly available on the web
Maybe something like this would work:
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
Dim week As Integer
week = (d.DayOfYear - isoDayOfWeek + 10) / 7
Thanks @Paul Lefebvre!
I was just about to create that calculation myself when I found yours
Seems to work just fine.
Now, add it to the date class.
WeekOfYearISO function works different on Windows and MacOS.
d.day = 1
d.month = 1
d.year = 2016
Windows shows week number 53
MacOS show week number 0