I am try to find a nice way to work out the week number from a non standard starting date. Week 1 shall contain the first Sunday in April. To calculate this, I just loop through the first 7 days in April til I find the first Sunday. Weeks will start on Sunday.
Normally I would attempt to solve this doing something like this:
numberOfDaysDifferenceBetweenEpoch / 7 % 52 + 1;
However about every 5 years it works out as there are 53 weeks in a year. Obviously the function above will not work if it happens to be a 53 week year. An easy solution would be just to make two functions, which take the modulus of 52 or 53 however I'm hoping there is a cleaner way of doing this. What would the best way to approach this problem?