angular-ui/bootstrap — pull request #1701 by Foxandxss (2014-01-30 11:02:07+00:00)
Title: fix(datepicker): correctly change months

This fixes #1697

The problem is that when we have let's say day 30 of January and we do a `setMonth` to change it to February, since February doesn't have 30 days, `setMonth` will try to fix it selecting the last day available (28) and then adds the rest of days, so it will select `March 02`. That is why it skips the month.

I also tested going back, from `March 30` to `February` It fails, it doesn't skip the month, it directly doesn't change. (Same problem, `setMonth` would try to put February but when it adds the two extra days, it ends on March, so it doesn't change). Clicking again changes ok (Because the selected date will have `2` as the day).

Anyway, since we need `selected` for calendar purposes (not for the selected date) we can just put the day as the day `1` (so no month can cry) when we move through months. That way you won't skip months anymore.