aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-05-04 01:35:11 +0100
committerArun Isaac2024-05-04 01:39:14 +0100
commit5f5b155eb0774a0e27b8fc68ca16ab8a9dfb4d8d (patch)
tree8160ca6bd93d00f50c2f8af5118cd27f54f3d5e1
parent9a82c0ceb9824960ec8f9c560af8dad67afb0517 (diff)
downloadguile-xapian-5f5b155eb0774a0e27b8fc68ca16ab8a9dfb4d8d.tar.gz
guile-xapian-5f5b155eb0774a0e27b8fc68ca16ab8a9dfb4d8d.tar.lz
guile-xapian-5f5b155eb0774a0e27b8fc68ca16ab8a9dfb4d8d.zip
xapian: Wrap DateRangeProcessor.
* xapian/xapian.scm (prefixed-date-range-processor, suffixed-date-range-processor): New public functions.
-rw-r--r--xapian/xapian.scm36
1 files changed, 36 insertions, 0 deletions
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