[evolution/gnome-43] I#2013 - Tasks: Correct interpretation of Due DATE value
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-43] I#2013 - Tasks: Correct interpretation of Due DATE value
- Date: Fri, 16 Sep 2022 07:00:58 +0000 (UTC)
commit 57bb0f0d838229bc71c7b01d38f23f7e93f5f8a5
Author: Milan Crha <mcrha redhat com>
Date: Fri Sep 16 08:59:22 2022 +0200
I#2013 - Tasks: Correct interpretation of Due DATE value
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/2013
src/calendar/gui/e-cal-model-tasks.c | 12 ++++++---
src/calendar/gui/e-to-do-pane.c | 50 ++++++++++++++++++++++++++++++++----
2 files changed, 54 insertions(+), 8 deletions(-)
---
diff --git a/src/calendar/gui/e-cal-model-tasks.c b/src/calendar/gui/e-cal-model-tasks.c
index 7ca3074742..cef7e4e161 100644
--- a/src/calendar/gui/e-cal-model-tasks.c
+++ b/src/calendar/gui/e-cal-model-tasks.c
@@ -323,17 +323,23 @@ get_due_status (ECalModelTasks *model,
/* Third, are we overdue as of right now? */
due_tt = i_cal_property_get_due (prop);
if (i_cal_time_is_date (due_tt)) {
+ ICalTimezone *zone = e_cal_model_get_timezone (E_CAL_MODEL (model));
gint cmp;
- now_tt = i_cal_time_new_current_with_zone (e_cal_model_get_timezone (E_CAL_MODEL
(model)));
- cmp = i_cal_time_compare_date_only (due_tt, now_tt);
+ /* The DATE value means it's overdue at the beginning of the day */
+ i_cal_time_adjust (due_tt, -1, 0, 0, 0);
+
+ now_tt = i_cal_time_new_current_with_zone (zone);
+ cmp = i_cal_time_compare_date_only_tz (due_tt, now_tt, zone);
g_object_unref (now_tt);
g_object_unref (due_tt);
g_object_unref (prop);
- if (cmp <= 0)
+ if (cmp < 0)
return E_CAL_MODEL_TASKS_DUE_OVERDUE;
+ else if (cmp == 0)
+ return E_CAL_MODEL_TASKS_DUE_TODAY;
else
return E_CAL_MODEL_TASKS_DUE_FUTURE;
} else {
diff --git a/src/calendar/gui/e-to-do-pane.c b/src/calendar/gui/e-to-do-pane.c
index 47887e6161..e9c656a304 100644
--- a/src/calendar/gui/e-to-do-pane.c
+++ b/src/calendar/gui/e-to-do-pane.c
@@ -205,6 +205,26 @@ etdp_itt_to_zone (ICalTime *itt,
}
}
+static gboolean
+etdp_task_is_overdue (ICalTime *itt,
+ guint today_date_mark)
+{
+ gboolean is_overdue;
+
+ if (!i_cal_time_is_date (itt))
+ return etdp_create_date_mark (itt) < today_date_mark;
+
+ /* The DATE value means it's overdue at the beginning of the day */
+ i_cal_time_adjust (itt, -1, 0, 0, 0);
+
+ is_overdue = etdp_create_date_mark (itt) < today_date_mark;
+
+ /* Restore the original date */
+ i_cal_time_adjust (itt, 1, 0, 0, 0);
+
+ return is_overdue;
+}
+
static gchar *
etdp_date_time_to_string (const ECalComponentDateTime *dt,
ECalClient *client,
@@ -225,8 +245,7 @@ etdp_date_time_to_string (const ECalComponentDateTime *dt,
etdp_itt_to_zone (*out_itt, e_cal_component_datetime_get_tzid (dt), client, default_zone);
- is_overdue = is_task && (etdp_create_date_mark (*out_itt) < today_date_mark ||
- (i_cal_time_is_date (*out_itt) && etdp_create_date_mark (*out_itt) <= today_date_mark));
+ is_overdue = is_task && etdp_task_is_overdue (*out_itt, today_date_mark);
if (i_cal_time_is_date (*out_itt) && !is_overdue)
return NULL;
@@ -396,6 +415,7 @@ etdp_get_component_data (EToDoPane *to_do_pane,
prefix = "1";
dtstart = e_cal_component_get_dtstart (comp);
+ /* Do not use etdp_get_task_due() here, to show the set date in the GUI */
dt = e_cal_component_get_due (comp);
completed = e_cal_component_get_completed (comp);
@@ -626,6 +646,26 @@ etdp_get_fgcolor_for_bgcolor (const GdkRGBA *bgcolor)
return fgcolor;
}
+static ECalComponentDateTime *
+etdp_get_task_due (ECalComponent *comp)
+{
+ ECalComponentDateTime *dt;
+
+ dt = e_cal_component_get_due (comp);
+
+ if (dt && e_cal_component_datetime_get_value (dt)) {
+ ICalTime *itt;
+
+ itt = e_cal_component_datetime_get_value (dt);
+ if (i_cal_time_is_date (itt)) {
+ /* The DATE value means it's overdue at the beginning of the day */
+ i_cal_time_adjust (itt, -1, 0, 0, 0);
+ }
+ }
+
+ return dt;
+}
+
static GSList * /* GtkTreePath * */
etdp_get_component_root_paths (EToDoPane *to_do_pane,
ECalClient *client,
@@ -645,7 +685,7 @@ etdp_get_component_root_paths (EToDoPane *to_do_pane,
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_TODO) {
- dt = e_cal_component_get_due (comp);
+ dt = etdp_get_task_due (comp);
if (dt && e_cal_component_datetime_get_value (dt)) {
itt = e_cal_component_datetime_get_value (dt);
@@ -896,7 +936,7 @@ etdp_get_comp_colors (EToDoPane *to_do_pane,
to_do_pane->priv->overdue_color) {
ECalComponentDateTime *dt;
- dt = e_cal_component_get_due (comp);
+ dt = etdp_get_task_due (comp);
if (dt && e_cal_component_datetime_get_value (dt)) {
ICalTimezone *default_zone;
@@ -912,7 +952,7 @@ etdp_get_comp_colors (EToDoPane *to_do_pane,
now = i_cal_time_new_current_with_zone (default_zone);
i_cal_time_set_timezone (now, default_zone);
- if ((is_date && i_cal_time_compare_date_only (itt, now) <= 0) ||
+ if ((is_date && i_cal_time_compare_date_only_tz (itt, now, default_zone) < 0) ||
(!is_date && i_cal_time_compare (itt, now) <= 0)) {
bgcolor = to_do_pane->priv->overdue_color;
} else if (out_nearest_due) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]