It's tougher than I expected. I somewhat knew this the first time I started talking about it (and ever since, see the Obligatory Sidebar Links). It's not really about the code, but about the design—how should I do it?
The problem I have is one of extreme flexibility here—the code allows me to display an entire year, an entire month, as well as a day and even arbitrary range of days. If a person selects the archive of a month, she should then get a list of days, plus maybe the titles of each entry—yet if she picks a large enough range of months (say, six months) then that might get too large.
So then I'm thinking that if the number of days exceeds some threshhold (like, 60 days) then just list the months and days, and if it exceeds some larger threshhold (like 180 days) then just list the months.
But then, if someone selects something like seven months, two full days and a half day, then what? Perhaps I should just give what was asked for. Perhaps.
I identified thirteen specific cases to examine:
|Specification||What I should return|
|nothing specified||years only?|
|y/m||list days and entries|
[I should note that as I was doing the table, I originally had sixteen cases, but found out that three cases could not happen (which goes to show I don't even fully understand my own code) so I no longer have to worry about them.]
Entries are automatically archived, and displaying an arbitrary range works fine now; I want the archive list to work automatically too. I should be able to add new entries and have the computer do everything else for me. After all, isn't that what a computer is for?