Fix bug with interval calculation.

This would fail on month intervals when the calculated month has less
days then the current day of the month.