Be aware that there are different definitions of "week number": one that is prevalent in the US, and one (recommended by the ISO) used more in Europe. A US week 32 could be an ISO week 31 or vice versa. This might not be important for your case, but don't let it surprise you.
Thank you for pointing that out, bens, but I'm aware of that. According to the ISO standard week 01 is the first week of the year that contains a Thursday (or 4th January). I think that is exactly what Dwights script is calculating.