diff --git a/src/engine/Query.c b/src/engine/Query.c index 30f5aced96..5c5878d05b 100644 --- a/src/engine/Query.c +++ b/src/engine/Query.c @@ -194,6 +194,16 @@ xaccQuerySetMaxSplits (Query *q, int max) /* ================================================== */ +void +xaccQuerySetDateRange (Query *q, time_t early, time_t late) +{ + if (!q) return; + q->earliest.tv_sec = early; + q->latest.tv_sec = late; +} + +/* ================================================== */ + #define PROLOG \ char *da, *db; \ Transaction *ta; \ @@ -634,7 +644,7 @@ xaccQueryGetSplits (Query *q) time_t xaccQueryGetEarliestDateFound (Query *q) { - if (!q) return NULL; + if (!q) return 0; return ((time_t) q->earliest_found.tv_sec); } @@ -642,7 +652,7 @@ xaccQueryGetEarliestDateFound (Query *q) time_t xaccQueryGetLatestDateFound (Query *q) { - if (!q) return NULL; + if (!q) return ULONG_MAX; return ((time_t) q->latest_found.tv_sec); } diff --git a/src/engine/Query.h b/src/engine/Query.h index 14bb95db15..e1f0255b75 100644 --- a/src/engine/Query.h +++ b/src/engine/Query.h @@ -60,6 +60,12 @@ void xaccQueryAddAccount (Query *, Account *acc); */ void xaccQuerySetMaxSplits (Query *, int); +/* The xaccQuerySetDateRange() method sets the date range + * for the query. Thje query will return only those splits + * that are within this date range. + */ +void xaccQuerySetDateRange (Query *, time_t earliest, time_t latest); + /* The xaccQuerySetSortOrder() method sets the sort order that * should be used on the splits. The three arguments should * be choosen from the enums above. The first argument has the