Calculating ISO8601 week numbers in LotusScript

Lotus Domino’s LotusScript language has a function called Format. If you pass it a date/time value, and use the custom format string "ww", it’s supposed to return the week number.

Unfortunately, it returns the wrong value. I was prepared to be charitable and assume that it returned the correct value according to some non-standard algorithm, but since the documentation didn’t specify the algorithm, I reported the behavior as a bug. My SPR got filed in the “Yes, it’s a bug, but we won’t fix it” pile, so here’s the workaround: LotusScript code to calculate week numbers as per ISO 8601. (Available on GitHub)