GNOME Bugzilla – Bug 641067
Calendar: go to next/prev month
Last modified: 2011-01-31 20:31:21 UTC
<xan> davidz: shell master, open calendar, click 'next' on the month thingie, it jumps to March <xan> going back works ok, goes to february and then january and if after that you try to go forward it works ok too --> jg (~jg@c-98-229-99-32.hsd1.ma.comcast.net) has joined #fedora-desktop <davidz> xan: oh, fun xan: it does that because there is no February 31 :-) the question is what it should be doing... (probably not what it is doing right now) <drago01> go to the 28 st <davidz> maybe (probably even) <xan> seems like the most sensible thing to do, yeah This is probably due to how the Date class works, relevant code: _onPrevMonthButtonClicked: function() { let newDate = new Date(this._selectedDate); if (newDate.getMonth() == 0) { newDate.setMonth(11); newDate.setFullYear(newDate.getFullYear() - 1); } else { newDate.setMonth(newDate.getMonth() - 1); } this.setDate(newDate); }, _onNextMonthButtonClicked: function() { let newDate = new Date(this._selectedDate); if (newDate.getMonth() == 11) { newDate.setMonth(0); newDate.setFullYear(newDate.getFullYear() + 1); } else { newDate.setMonth(newDate.getMonth() + 1); } this.setDate(newDate); },
Created attachment 179745 [details] [review] calendar: Fix prev/next buttons to not skip months When the current day does not exist in the next/prev month (like 31 Feb), the next/prev buttons end up skipping the month. Fix that by going to the last day of the month instead.
Looks good to me, please commit. Thanks!
Attachment 179745 [details] pushed as 8fea888 - calendar: Fix prev/next buttons to not skip months