Merge lp:~davidmhewitt/wingpanel-indicator-datetime/fix-1668175 into lp:~wingpanel-devs/wingpanel-indicator-datetime/trunk

Proposed by David Hewitt
Status: Merged
Approved by: Danielle Foré
Approved revision: 181
Merged at revision: 181
Proposed branch: lp:~davidmhewitt/wingpanel-indicator-datetime/fix-1668175
Merge into: lp:~wingpanel-devs/wingpanel-indicator-datetime/trunk
Diff against target: 27 lines (+10/-2)
1 file modified
src/Widgets/calendar/CalendarView.vala (+10/-2)
To merge this branch: bzr merge lp:~davidmhewitt/wingpanel-indicator-datetime/fix-1668175
Reviewer Review Type Date Requested Status
WingPanel Devs Pending
Review via email: mp+318351@code.launchpad.net

Commit message

Prevent skipping months by checking bounds of next/previous month

Description of the change

Previously, the indicator would try to go to the same date in the next/previous month. It didn't do any checks to see if the new month had enough days. So if you were on the last day of the month, and the next/previous month had less days, it would skip ahead 2 months.

Now, when you go to the next month, if there aren't enough days in the month, it simply selects the last day of the month instead.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/calendar/CalendarView.vala'
2--- src/Widgets/calendar/CalendarView.vala 2016-07-11 18:57:51 +0000
3+++ src/Widgets/calendar/CalendarView.vala 2017-02-27 12:20:25 +0000
4@@ -138,7 +138,15 @@
5
6 // keep focus date on the same day of the month
7 if (selected_date != null) {
8- var bumpdate = model.month_start.add_days (selected_date.get_day_of_month() - 1);
9+ var month = (GLib.DateMonth)model.month_start.get_month ();
10+ var year = (GLib.DateYear)model.month_start.get_year ();
11+ int days_in_month = GLib.Date.get_days_in_month (month, year);
12+ GLib.DateTime bumpdate;
13+ if (selected_date.get_day_of_month () > days_in_month) {
14+ bumpdate = model.month_start.add_days (days_in_month - 1);
15+ } else {
16+ bumpdate = model.month_start.add_days (selected_date.get_day_of_month() - 1);
17+ }
18 grid.focus_date (bumpdate);
19 }
20
21@@ -156,4 +164,4 @@
22 return false;
23 });
24 }
25-}
26\ No newline at end of file
27+}

Subscribers

People subscribed via source and target branches