From cf9692f1e93fd32759530fa98ec7b5947795eb6d Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 May 2009 13:52:37 +0100 Subject: [PATCH] Don't return history data relative to the earliest point, only within the time period given --- src/dkp-history.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/dkp-history.c b/src/dkp-history.c index 175bd38..e383e02 100644 --- a/src/dkp-history.c +++ b/src/dkp-history.c @@ -196,7 +196,7 @@ dkp_history_copy_array_timespan (const GPtrArray *array, guint timespan) guint i; const DkpHistoryObj *obj; GPtrArray *array_new; - guint start; + GTimeVal timeval; /* no data */ if (array->len == 0) @@ -204,14 +204,13 @@ dkp_history_copy_array_timespan (const GPtrArray *array, guint timespan) /* new data */ array_new = g_ptr_array_new (); + g_get_current_time (&timeval); /* treat the timespan like a range, and search backwards */ - obj = (const DkpHistoryObj *) g_ptr_array_index (array, array->len-1); - start = obj->time; timespan *= 0.95f; for (i=array->len-1; i>0; i--) { obj = (const DkpHistoryObj *) g_ptr_array_index (array, i); - if (start - obj->time < timespan) + if (timeval.tv_sec - obj->time < timespan) g_ptr_array_add (array_new, dkp_history_obj_copy (obj)); }