Calendar rebase (2)

This replaces #1316.
If `months[ i ].first` and `months[ i ].last` are mutually exclusive, I suggest using `else if`.