From 62b6419332e4c19f08a59cad915cca4c4663a179 Mon Sep 17 00:00:00 2001 From: Andreas Brauchli Date: Wed, 17 Sep 2014 15:34:40 -1000 Subject: [PATCH] Calendar: sort multi-day events by ending day/time With commit dc6a60dde, the calendar displays the ending day and time of a continuing multi-day event on its ending day. This results in the list not appearing to be sorted. This patch sorts the list according to the displayed day/time. With the two appointments Thursday 0800-1000 Foo, and Wednesday 0900-Friday 1200 Bar and today being Monday, the rest of the week list currently displays: F ...1200 Bar T 0800 Foo With this patch, the displaying order is switched because Friday comes after Thursday. https://bugzilla.gnome.org/show_bug.cgi?id=727302 --- js/ui/calendar.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 3899ecb81..2c4368901 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -383,6 +383,12 @@ const DBusEventSource = new Lang.Class({ result.push(event); } } + result.sort(function(event1, event2) { + // sort events by end time on ending day + let d1 = event1.date < begin && event1.end <= end ? event1.end : event1.date; + let d2 = event2.date < begin && event2.end <= end ? event2.end : event2.date; + return d1.getTime() - d2.getTime(); + }); return result; },