From daf0cbf0df354753382b43c5ca21275a4722761a Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 26 Sep 2023 10:29:31 +0100 Subject: Add date comparison predicates. * rent.scm (make-date-comparer, date<=?, date>=?): New functions. --- rent.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'rent.scm') diff --git a/rent.scm b/rent.scm index 238d97c..4d4855e 100644 --- a/rent.scm +++ b/rent.scm @@ -154,6 +154,19 @@ somewhere in @var{html}, a string." (add-duration (date->time-utc date) (make-time time-duration 0 (* days 24 60 60))))) +(define (make-date-comparer time-predicate) + "Return a predicate that compares two dates by converting them to +times and comparing them using @var{time-predicate}." + (lambda (date1 date2) + (time-predicate (date->time-utc date1) + (date->time-utc date2)))) + +(define date<=? + (make-date-comparer time<=?)) + +(define date>=? + (make-date-comparer time>=?)) + (define (all-houses) "Return a list of all houses on the OpenRent index page." (let ((html (bytevector->string (http-get* %openrent-index-url -- cgit v1.2.3