From 1f2031899cdb9754574dbf3005e17587fa77993c Mon Sep 17 00:00:00 2001 From: Iván Frade Date: Wed, 6 Oct 2004 16:33:28 +0000 Subject: Fixes #48116 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2004-10-02 Iván Frade Fixes #48116 * gui/dialogs/task-details.page.c (task_details_page_fill_component): Validation: completed date is not a future date. svn path=/trunk/; revision=27480 --- calendar/gui/dialogs/task-details-page.c | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'calendar/gui/dialogs') diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index d5fa0465cf..9e88e915b8 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -393,12 +393,13 @@ task_details_page_fill_component (CompEditorPage *page, ECalComponent *comp) { TaskDetailsPage *tdpage; TaskDetailsPagePrivate *priv; - struct icaltimetype icaltime; + struct icaltimetype icalcomplete, icaltoday; icalproperty_status status; TaskEditorPriority priority; int priority_value, percent; char *url; gboolean date_set; + icaltimezone *zone = calendar_config_get_icaltimezone (); tdpage = TASK_DETAILS_PAGE (page); priv = tdpage->priv; @@ -416,10 +417,10 @@ task_details_page_fill_component (CompEditorPage *page, ECalComponent *comp) priority_value = priority_index_to_value (priority); e_cal_component_set_priority (comp, &priority_value); - icaltime = icaltime_null_time (); + icalcomplete = icaltime_null_time (); /* COMPLETED must be in UTC. */ - icaltime.is_utc = 1; + icalcomplete.is_utc = 1; /* Completed Date. */ if (!e_date_edit_date_is_valid (E_DATE_EDIT (priv->completed_date)) || @@ -429,12 +430,24 @@ task_details_page_fill_component (CompEditorPage *page, ECalComponent *comp) } date_set = e_date_edit_get_date (E_DATE_EDIT (priv->completed_date), - &icaltime.year, - &icaltime.month, - &icaltime.day); + &icalcomplete.year, + &icalcomplete.month, + &icalcomplete.day); + e_date_edit_get_time_of_day (E_DATE_EDIT (priv->completed_date), - &icaltime.hour, - &icaltime.minute); + &icalcomplete.hour, + &icalcomplete.minute); + + /* COMPLETED today or before */ + icaltoday = icaltime_current_time_with_zone (zone); + icaltimezone_convert_time (&icaltoday, zone, + icaltimezone_get_utc_timezone()); + + if (icaltime_compare_date_only (icalcomplete, icaltoday) > 0) { + comp_editor_page_display_validation_error (page, _("Completed date is wrong"), priv->completed_date); + return FALSE; + } + if (date_set) { /* COMPLETED must be in UTC, so we assume that the date in the dialog is in the current timezone, and we now convert it @@ -442,10 +455,9 @@ task_details_page_fill_component (CompEditorPage *page, ECalComponent *comp) entire time the dialog is shown. Otherwise if the user changes the timezone, the COMPLETED date may get changed as well. */ - icaltimezone *zone = calendar_config_get_icaltimezone (); - icaltimezone_convert_time (&icaltime, zone, + icaltimezone_convert_time (&icalcomplete, zone, icaltimezone_get_utc_timezone ()); - e_cal_component_set_completed (comp, &icaltime); + e_cal_component_set_completed (comp, &icalcomplete); } else { e_cal_component_set_completed (comp, NULL); } -- cgit