Fix timestamp tests if month changes

On the last and first day of a month, simply adding a day or subtracting
a day will cause the day to go out of bounds. So if the month changes,
it's probably the last or first day of a month.

Bug: T76285
Change-Id: Ibeb12f4f911c0bc9d40a92ca718464a90082f428