[evolution/gnome-3-2] Bug #659568 - One day delay in calendar view



commit 8a8087fac4c1ff229be021e452ad0b67916cc1f2
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 26 12:44:38 2011 +0200

    Bug #659568 - One day delay in calendar view

 calendar/gui/e-cal-model.c          |   18 +++++++++------
 calendar/gui/gnome-cal.c            |   40 ++++++++++++++++++++++------------
 modules/calendar/e-cal-shell-view.c |   16 ++++++++-----
 3 files changed, 47 insertions(+), 27 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index f177913..1ab5692 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -3160,20 +3160,24 @@ redo_queries (ECalModel *model)
 
 	if (priv->start != -1 && priv->end != -1) {
 		gchar *iso_start, *iso_end;
+		const gchar *default_tzloc = NULL;
 
 		iso_start = isodate_from_time_t (priv->start);
 		iso_end = isodate_from_time_t (priv->end);
 
+		if (priv->zone && priv->zone != icaltimezone_get_utc_timezone ())
+			default_tzloc = icaltimezone_get_location (priv->zone);
+		if (!default_tzloc)
+			default_tzloc = "";
+
 		if (priv->search_sexp) {
-			priv->full_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\")"
-					"                           (make-time \"%s\"))"
-					"     %s)",
-					iso_start, iso_end,
+			priv->full_sexp = g_strdup_printf (
+					"(and (occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\") %s)",
+					iso_start, iso_end, default_tzloc,
 					priv->search_sexp ? priv->search_sexp : "");
 		} else {
-			priv->full_sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
-					"                           (make-time \"%s\"))",
-					iso_start, iso_end);
+			priv->full_sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\")",
+					iso_start, iso_end, default_tzloc);
 		}
 
 		g_free (iso_start);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index cf1a12d..654eb18 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1016,6 +1016,24 @@ get_date_navigator_range (GnomeCalendar *gcal,
 	*end_time = icaltime_as_timet_with_zone (end_tt, timezone);
 }
 
+static const gchar *
+gcal_get_default_tzloc (GnomeCalendar *gcal)
+{
+	ECalModel *model;
+	icaltimezone *timezone;
+	const gchar *tzloc = NULL;
+
+	g_return_val_if_fail (gcal != NULL, "");
+
+	model = gnome_calendar_get_model (gcal);
+	timezone = e_cal_model_get_timezone (model);
+
+	if (timezone && timezone != icaltimezone_get_utc_timezone ())
+		tzloc = icaltimezone_get_location (timezone);
+
+	return tzloc ? tzloc : "";
+}
+
 /* Adjusts a given query sexp with the time range of the date navigator */
 static gchar *
 adjust_client_view_sexp (GnomeCalendar *gcal,
@@ -1033,15 +1051,12 @@ adjust_client_view_sexp (GnomeCalendar *gcal,
 	end = isodate_from_time_t (end_time);
 
 	if (sexp) {
-		new_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\")"
-				"                           (make-time \"%s\"))"
-				"     %s)",
-				start, end,
+		new_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\") %s)",
+				start, end, gcal_get_default_tzloc (gcal),
 				sexp);
 	} else {
-		new_sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
-				"                     (make-time \"%s\"))",
-				start, end);
+		new_sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\")",
+				start, end, gcal_get_default_tzloc (gcal));
 	}
 
 	g_free (start);
@@ -1366,10 +1381,8 @@ update_memo_view (GnomeCalendar *gcal)
 		g_free (priv->memo_sexp);
 
 		priv->memo_sexp = g_strdup_printf (
-			"(and (or (not (has-start?)) "
-			"(occur-in-time-range? (make-time \"%s\")"
-			" (make-time \"%s\"))) %s)",
-			iso_start, iso_end,
+			"(and (or (not (has-start?)) (occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\")) %s)",
+			iso_start, iso_end, gcal_get_default_tzloc (gcal),
 			priv->sexp ? priv->sexp : "");
 
 		e_cal_model_set_search_query (model, priv->memo_sexp);
@@ -2243,9 +2256,8 @@ gnome_calendar_purge (GnomeCalendar *gcal,
 
 	start = isodate_from_time_t (0);
 	end = isodate_from_time_t (older_than);
-	sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
-				"                      (make-time \"%s\"))",
-				start, end);
+	sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\")",
+				start, end, gcal_get_default_tzloc (gcal));
 
 	gcal_update_status_message (gcal, _("Purging"), -1);
 
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index 61a2d9c..0a9b770 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -70,6 +70,7 @@ cal_shell_view_execute_search (EShellView *shell_view)
 	ECalModel *model;
 	GtkRadioAction *action;
 	icaltimezone *timezone;
+	const gchar *default_tzloc = NULL;
 	struct icaltimetype current_time;
 	time_t start_range;
 	time_t end_range;
@@ -95,6 +96,11 @@ cal_shell_view_execute_search (EShellView *shell_view)
 	current_time = icaltime_current_time_with_zone (timezone);
 	now_time = time_day_begin (icaltime_as_timet (current_time));
 
+	if (timezone && timezone != icaltimezone_get_utc_timezone ())
+		default_tzloc = icaltimezone_get_location (timezone);
+	if (!default_tzloc)
+		default_tzloc = "";
+
 	action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
 	value = gtk_radio_action_get_current_value (action);
 
@@ -165,9 +171,8 @@ cal_shell_view_execute_search (EShellView *shell_view)
 			end = isodate_from_time_t (end_range);
 
 			temp = g_strdup_printf (
-				"(and %s (occur-in-time-range? "
-				"(make-time \"%s\") (make-time \"%s\")))",
-				query, start, end);
+				"(and %s (occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\"))",
+				query, start, end, default_tzloc);
 			g_free (query);
 			query = temp;
 
@@ -181,9 +186,8 @@ cal_shell_view_execute_search (EShellView *shell_view)
 			end = isodate_from_time_t (end_range);
 
 			temp = g_strdup_printf (
-				"(and %s (occur-in-time-range? "
-				"(make-time \"%s\") (make-time \"%s\")))",
-				query, start, end);
+				"(and %s (occur-in-time-range? (make-time \"%s\") (make-time \"%s\") \"%s\"))",
+				query, start, end, default_tzloc);
 			g_free (query);
 			query = temp;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]