pageranges.py: work around being handed invalid dates

People can give us calendar-based URLs for invalid dates, like
2006/06/32. We used to not notice this, but datetime.date() throws an
exception on this kind of shenanigans so we need to work around things.
The current workaround is kind of a hack job.