aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-cell-date-edit-text.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-01-20 22:48:31 +0800
committerMilan Crha <mcrha@redhat.com>2010-01-20 22:48:31 +0800
commit41dfcdb070f5c052908ca15bb304c91ae637795c (patch)
treed606ed14fc7d7c97e1a13d268e31209303ec5d34 /calendar/gui/e-cell-date-edit-text.c
parent7861651506746fe8cbd15e4cec9ab38d8e1073f3 (diff)
downloadgsoc2013-evolution-41dfcdb070f5c052908ca15bb304c91ae637795c.tar.gz
gsoc2013-evolution-41dfcdb070f5c052908ca15bb304c91ae637795c.tar.zst
gsoc2013-evolution-41dfcdb070f5c052908ca15bb304c91ae637795c.zip
Bug #606301 - Slow sort by subject
Diffstat (limited to 'calendar/gui/e-cell-date-edit-text.c')
-rw-r--r--calendar/gui/e-cell-date-edit-text.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/calendar/gui/e-cell-date-edit-text.c b/calendar/gui/e-cell-date-edit-text.c
index bebec0fcda..37886680e5 100644
--- a/calendar/gui/e-cell-date-edit-text.c
+++ b/calendar/gui/e-cell-date-edit-text.c
@@ -361,3 +361,28 @@ e_cell_date_edit_text_set_use_24_hour_format (ECellDateEditText *ecd,
g_object_notify (G_OBJECT (ecd), "use-24-hour-format");
}
+gint
+e_cell_date_edit_compare_cb (gconstpointer a, gconstpointer b, gpointer cmp_cache)
+{
+ ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
+ ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
+ struct icaltimetype tt;
+
+ /* First check if either is NULL. NULL dates sort last. */
+ if (!dv1 || !dv2) {
+ if (dv1 == dv2)
+ return 0;
+ else if (dv1)
+ return -1;
+ else
+ return 1;
+ }
+
+ /* Copy the 2nd value and convert it to the same timezone as the first. */
+ tt = dv2->tt;
+
+ icaltimezone_convert_time (&tt, dv2->zone, dv1->zone);
+
+ /* Now we can compare them. */
+ return icaltime_compare (dv1->tt, tt);
+}