After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641067 - Calendar: go to next/prev month
Calendar: go to next/prev month
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-01-31 19:35 UTC by David Zeuthen (not reading bugmail)
Modified: 2011-01-31 20:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
calendar: Fix prev/next buttons to not skip months (2.71 KB, patch)
2011-01-31 20:02 UTC, drago01
committed Details | Review

Description David Zeuthen (not reading bugmail) 2011-01-31 19:35:11 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);
    },
Comment 1 drago01 2011-01-31 20:02:17 UTC
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.
Comment 2 David Zeuthen (not reading bugmail) 2011-01-31 20:28:55 UTC
Looks good to me, please commit. Thanks!
Comment 3 drago01 2011-01-31 20:31:17 UTC
Attachment 179745 [details] pushed as 8fea888 - calendar: Fix prev/next buttons to not skip months