diff --git a/js/ui/calendar.js b/js/ui/calendar.js index f803de54a..236c3ec67 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -41,6 +41,7 @@ function _getBeginningOfDay(date) { let ret = new Date(date.getTime()); ret.setHours(0); ret.setMinutes(0); + ret.setSeconds(0); ret.setMilliseconds(0); return ret; } @@ -49,6 +50,7 @@ function _getEndOfDay(date) { let ret = new Date(date.getTime()); ret.setHours(23); ret.setMinutes(59); + ret.setSeconds(59); ret.setMilliseconds(999); return ret; } @@ -686,21 +688,24 @@ EventsList.prototype = { let dayEnd = _getEndOfDay(now); this._addPeriod(_("Today"), dayBegin, dayEnd, false, true); - dayBegin.setDate(dayBegin.getDate() + 1); - dayEnd.setDate(dayEnd.getDate() + 1); - this._addPeriod(_("Tomorrow"), dayBegin, dayEnd, false, true); + let tomorrowBegin = new Date(dayBegin.getTime() + 86400 * 1000); + let tomorrowEnd = new Date(dayEnd.getTime() + 86400 * 1000); + this._addPeriod(_("Tomorrow"), tomorrowBegin, tomorrowEnd, false, true); - if (dayEnd.getDay() == 6 || dayEnd.getDay() == 0) { - dayBegin.setDate(dayEnd.getDate() + 1); - dayEnd.setDate(dayBegin.getDate() + 6 - dayBegin.getDay()); - - this._addPeriod(_("Next week"), dayBegin, dayEnd, true, false); - return; + if (dayEnd.getDay() <= 4) { + /* if now is Sunday through Thursday show "This week" and include events up until + * and including Saturday + */ + let thisWeekBegin = new Date(dayBegin.getTime() + 2 * 86400 * 1000); + let thisWeekEnd = new Date(dayEnd.getTime() + (6 - dayEnd.getDay()) * 86400 * 1000); + this._addPeriod(_("This week"), thisWeekBegin, thisWeekEnd, true, false); } else { - let d = 6 - dayEnd.getDay() - 1; - dayBegin.setDate(dayBegin.getDate() + 1); - dayEnd.setDate(dayEnd.getDate() + 1 + d); - this._addPeriod(_("This week"), dayBegin, dayEnd, true, false); + /* otherwise it's a Friday or Saturday... show "Next week" and include events up + * until and including *next* Saturday + */ + let nextWeekBegin = new Date(dayBegin.getTime() + 2 * 86400 * 1000); + let nextWeekEnd = new Date(dayEnd.getTime() + (13 - dayEnd.getDay()) * 86400 * 1000); + this._addPeriod(_("Next week"), nextWeekBegin, nextWeekEnd, true, false); } }, diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 5ee3a5bc2..5009c2804 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -87,7 +87,7 @@ DateMenuButton.prototype = { item = new PopupMenu.PopupSeparatorMenuItem(); item.setColumnWidths(1); - vbox.add(item.actor); + vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false}); item = new PopupMenu.PopupMenuItem(_("Date and Time Settings")); item.connect('activate', Lang.bind(this, this._onPreferencesActivate)); vbox.add(item.actor); diff --git a/src/shell-evolution-event-source.c b/src/shell-evolution-event-source.c index 3c080e2a3..dd2aea91f 100644 --- a/src/shell-evolution-event-source.c +++ b/src/shell-evolution-event-source.c @@ -168,7 +168,7 @@ shell_evolution_event_source_get_events (ShellEvolutionEventSource *source, GDateTime *next_date; g_date_time_get_ymd (cur_date, &year, &mon, &day); - /* g_print ("y=%04d m=%02d d=%02d: ", year, mon, day); */ + /* g_print ("y=%04d m=%02d d=%02d\n", year, mon, day); */ /* Silently drop events not in range (see comment in * shell_evolution_event_source_request_range() above) @@ -188,9 +188,19 @@ shell_evolution_event_source_get_events (ShellEvolutionEventSource *source, { CalendarAppointment *appointment = l->data; ShellEvolutionEvent *event; + gint64 start_time; + + if (appointment->is_all_day) + { + start_time = g_date_time_to_unix (cur_date) * G_GINT64_CONSTANT (1000); + } + else + { + start_time = appointment->start_time * G_GINT64_CONSTANT (1000); + } event = shell_evolution_event_new (appointment->summary, appointment->is_all_day, - appointment->start_time * G_GINT64_CONSTANT (1000)); + start_time); result = g_list_prepend (result, event); } g_slist_foreach (events, (GFunc) calendar_event_free, NULL);