From 5f5b155eb0774a0e27b8fc68ca16ab8a9dfb4d8d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 4 May 2024 01:35:11 +0100 Subject: xapian: Wrap DateRangeProcessor. * xapian/xapian.scm (prefixed-date-range-processor, suffixed-date-range-processor): New public functions. --- xapian/xapian.scm | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'xapian') diff --git a/xapian/xapian.scm b/xapian/xapian.scm index 15690aa..f395162 100644 --- a/xapian/xapian.scm +++ b/xapian/xapian.scm @@ -56,6 +56,8 @@ query-filter prefixed-range-processor suffixed-range-processor + prefixed-date-range-processor + suffixed-date-range-processor field-processor enquire enquire-mset @@ -277,6 +279,40 @@ on both ends of the range—@samp{2kg..12kg}." (get-flag RP-REPEATED repeated?)) proc)) +(define* (prefixed-date-range-processor slot #:key (prefix "") repeated? prefer-mdy? (epoch-year 1970)) + "Return a @code{DateRangeProcessor} object that handles date ranges on +@var{slot}. + +@var{prefix} and @var{repeated?} are the same as in +@code{prefixed-range-processor}. + +When @var{prefer-mdy?} is @code{#t}, interpret ambiguous dates as +month/day/year rather than day/month/year. + +@var{epoch-year} is the year to use as the epoch for dates with +two-digit years." + (new-DateRangeProcessor slot + prefix + (bitwise-ior (get-flag (RP-REPEATED) repeated?) + (get-flag (RP-DATE-PREFER-MDY) prefer-mdy?)) + epoch-year)) + +(define* (suffixed-date-range-processor slot #:key suffix repeated? prefer-mdy? (epoch-year 1970)) + "Return a @code{DateRangeProcessor} object that handles date ranges on +@var{slot}. + +@var{suffix} and @var{repeated?} are the same as in +@code{suffixed-range-processor}. + +@var{prefer-mdy?} and @var{epoch-year} are the same as in +@code{prefixed-date-range-processor}." + (new-DateRangeProcessor slot + suffix + (bitwise-ior (RP-SUFFIX) + (get-flag (RP-REPEATED) repeated?) + (get-flag (RP-DATE-PREFER-MDY) prefer-mdy?)) + epoch-year)) + (define (field-processor proc) "Return a @code{FieldProcessor} object that calls @var{proc} to process its field. @var{proc} is a procedure that, given -- cgit v1.2.3