diff options
author | Milan Crha <mcrha@redhat.com> | 2012-08-25 00:05:09 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2012-08-25 00:05:52 +0800 |
commit | c4f35ce753df1c1c4cafc73070abc053090a7ba3 (patch) | |
tree | 2d77bbb1a5f81f2b5cd5c674db9bdb812781a466 /calendar | |
parent | d0dc48e6208cef870626a913330204f981584096 (diff) | |
download | gsoc2013-evolution-c4f35ce753df1c1c4cafc73070abc053090a7ba3.tar.gz gsoc2013-evolution-c4f35ce753df1c1c4cafc73070abc053090a7ba3.tar.zst gsoc2013-evolution-c4f35ce753df1c1c4cafc73070abc053090a7ba3.zip |
Bug #681669 - 'Select today' in work week view goes to wrong week
Diffstat (limited to 'calendar')
-rw-r--r-- | 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 dbd779b0a2..f656a3c894 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); |