Fixed week number function to properly roll forwards and backwards over year endings