[evolution-data-server] Bug #659568 - One day delay in calendar view



commit ef85fafac4d3793d8318e38e87d4329a7d01e92c
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 26 12:40:56 2011 +0200

    Bug #659568 - One day delay in calendar view

 calendar/libedata-cal/e-cal-backend-sexp.c |   30 ++++++++++++++++++++-------
 libedataserver/e-sexp.c                    |   19 ++++++++++++++++-
 2 files changed, 40 insertions(+), 9 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend-sexp.c b/calendar/libedata-cal/e-cal-backend-sexp.c
index 1076aa7..3758fb1 100644
--- a/calendar/libedata-cal/e-cal-backend-sexp.c
+++ b/calendar/libedata-cal/e-cal-backend-sexp.c
@@ -363,10 +363,12 @@ resolve_tzid (const gchar *tzid,
 	return e_cal_backend_internal_get_timezone (ctx->backend, tzid);
 }
 
-/* (occur-in-time-range? START END)
+/* (occur-in-time-range? START END TZLOC)
  *
- * START - time_t, start of the time range
- * END - time_t, end of the time range
+ * START - time_t, start of the time range, in UTC
+ * END - time_t, end of the time range, in UTC
+ * TZLOC - optional string with timezone location to use
+ *        as default timezone; if not set, UTC is used
  *
  * Returns a boolean indicating whether the component has any occurrences in the
  * specified time range.
@@ -380,12 +382,12 @@ func_occur_in_time_range (ESExp *esexp,
 	SearchContext *ctx = data;
 	time_t start, end;
 	ESExpResult *result;
-	icaltimezone *default_zone;
+	icaltimezone *default_zone = NULL;
 
 	/* Check argument types */
 
-	if (argc != 2) {
-		e_sexp_fatal_error (esexp, _("\"%s\" expects two arguments"),
+	if (argc != 2 && argc != 3) {
+		e_sexp_fatal_error (esexp, _("\"%s\" expects two or three arguments"),
 				    "occur-in-time-range");
 		return NULL;
 	}
@@ -406,9 +408,21 @@ func_occur_in_time_range (ESExp *esexp,
 	}
 	end = argv[1]->value.time;
 
-	/* See if the object occurs in the specified time range */
-	default_zone = icaltimezone_get_utc_timezone ();
+	if (argc == 3) {
+		if (argv[2]->type != ESEXP_RES_STRING) {
+			e_sexp_fatal_error (esexp, _("\"%s\" expects the third "
+						     "argument to be a string"),
+					    "occur-in-time-range");
+			return NULL;
+		}
+		
+		default_zone = resolve_tzid (argv[2]->value.string, ctx);
+	}
 
+	if (!default_zone)
+		default_zone = icaltimezone_get_utc_timezone ();
+
+	/* See if the object occurs in the specified time range */
 	ctx->occurs = FALSE;
 	e_cal_recur_generate_instances (ctx->comp, start, end,
 					(ECalRecurInstanceFn) check_instance_time_range_cb,
diff --git a/libedataserver/e-sexp.c b/libedataserver/e-sexp.c
index 86cbfa6..ac1dae9 100644
--- a/libedataserver/e-sexp.c
+++ b/libedataserver/e-sexp.c
@@ -887,6 +887,23 @@ const gchar *time_functions[] = {
 };
 
 static gboolean
+occur_in_time_range_generator (gint argc,
+                  struct _ESExpResult **argv,
+                  struct _ESExpResult *r)
+{
+	g_return_val_if_fail (r != NULL, FALSE);
+	g_return_val_if_fail (argc == 2 || argc == 3, FALSE);
+
+	if ((argv[0]->type != ESEXP_RES_TIME) || (argv[1]->type != ESEXP_RES_TIME))
+		return FALSE;
+
+	r->occuring_start = argv[0]->value.time;
+	r->occuring_end = argv[1]->value.time;
+
+	return TRUE;
+}
+
+static gboolean
 binary_generator (gint argc,
                   struct _ESExpResult **argv,
                   struct _ESExpResult *r)
@@ -925,7 +942,7 @@ static const struct {
 	const gchar *name;
 	ESGeneratorFunc *func;
 } generators[] = {
-	{"occur-in-time-range?", binary_generator},
+	{"occur-in-time-range?", occur_in_time_range_generator},
 	{"due-in-time-range?", binary_generator},
 	{"has-alarms-in-range?", binary_generator},
 	{"completed-before?", unary_generator},



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