What language? The example is pretty standard perl, although more readable if split onto more lines.
No elegant answer comes to mind, I'd have to say. We'd have to know your target language, so we could think of the standard date functions available, so we could think of a solution.
Notes: Weeks could be 1 to 6, by your definition. For weeks 1 to 5 ( or 4 in some cases!) this could be based on the n'th saturday. The kind of crocks that are half-forming in my mind are suggesting to me that this would be better not done: think up a different interface!
(Unless this is your homework, in which case the answer is to find out yourself.)
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
|