-}
-
-
-/*
- * Helper function for do_tasks_view(). Returns the due date/time of a vtodo.
- */
-time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
- icalproperty *p;
-
- if (vtodo == NULL) {
- return(0L);
- }
-
- /*
- * If we're looking at a fully encapsulated VCALENDAR
- * rather than a VTODO component, recurse into the data
- * structure until we get a VTODO.
- */
- if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
- return get_task_due_date(
- icalcomponent_get_first_component(
- vtodo, ICAL_VTODO_COMPONENT
- ), is_date
- );
- }
-
- p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
- if (p != NULL) {
- struct icaltimetype t = icalproperty_get_due(p);
-
- if (is_date)
- *is_date = t.is_date;
- return(icaltime_as_timet(t));
- }
- else {
- return(0L);
- }
-}
-
-
-/*
- * Compare the due dates of two tasks (this is for sorting)
- */
-int task_due_cmp(const void *vtask1, const void *vtask2) {
- disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
- disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
-
- time_t t1;
- time_t t2;
-
- t1 = get_task_due_date(Task1->cal, NULL);
- t2 = get_task_due_date(Task2->cal, NULL);
- if (t1 < t2) return(-1);
- if (t1 > t2) return(1);
- return(0);
-}
-
-/*
- * qsort filter to move completed tasks to bottom of task list
- */
-int task_completed_cmp(const void *vtask1, const void *vtask2) {
- disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
-/* disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2); */
-
- icalproperty_status t1 = icalcomponent_get_status((Task1)->cal);
- /* icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal); */
-
- if (t1 == ICAL_STATUS_COMPLETED)
- return 1;