[evolution] Bug #681669 - 'Select today' in work week view goes to wrong week
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #681669 - 'Select today' in work week view goes to wrong week
- Date: Fri, 24 Aug 2012 16:05:27 +0000 (UTC)
commit c4f35ce753df1c1c4cafc73070abc053090a7ba3
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 24 18:05:09 2012 +0200
Bug #681669 - 'Select today' in work week view goes to wrong week
calendar/gui/gnome-cal.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index dbd779b..f656a3c 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -920,11 +920,11 @@ get_times_for_views (GnomeCalendar *gcal,
/* The start of the work-week is the first working day after the
* week start day. */
- /* Get the weekday corresponding to start_time, 0 (Sun) to 6 (Sat). */
- weekday = g_date_get_weekday (&date) % 7;
+ /* Get the weekday corresponding to start_time, 0 (Mon) to 6 (Sun). */
+ weekday = (g_date_get_weekday (&date) + 6) % 7;
- /* Find the first working day in the week, 0 (Sun) to 6 (Sat). */
- first_day = (week_start_day + 1) % 7;
+ /* Find the first working day in the week, 0 (Mon) to 6 (Sun). */
+ first_day = week_start_day % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << first_day)) {
has_working_days = TRUE;
@@ -935,7 +935,7 @@ get_times_for_views (GnomeCalendar *gcal,
if (has_working_days) {
/* Now find the last working day of the week, backwards. */
- last_day = week_start_day % 7;
+ last_day = (first_day + 6) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << last_day))
break;
@@ -951,12 +951,12 @@ get_times_for_views (GnomeCalendar *gcal,
/* Calculate how many days we need to go back to the first workday. */
if (weekday < first_day) {
- offset = (first_day - weekday) % 7;
- g_date_add_days (&date, offset);
+ offset = (7 - first_day + weekday) % 7;
} else {
offset = (weekday - first_day) % 7;
- g_date_subtract_days (&date, offset);
}
+ if (offset)
+ g_date_subtract_days (&date, offset);
tt.year = g_date_get_year (&date);
tt.month = g_date_get_month (&date);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]