New date class

We were doing a lot of complicated time operations to figure out, e.g., what
month we were starting in, whether it was the end of the calendar year or a
multiple of 365 days had passed.  Now all these operations are handled in one
place, which makes the code easier to read and bugs in the date handling easier
to see.