aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-09-26 10:29:31 +0100
committerArun Isaac2023-09-26 10:29:31 +0100
commitdaf0cbf0df354753382b43c5ca21275a4722761a (patch)
treeed5635cd38d2e908b6e5ea1dff819d61c97fc94b
parentb466a96db3ceeddc8f28814309ba1bae9136ccbd (diff)
downloadrent-in-london-daf0cbf0df354753382b43c5ca21275a4722761a.tar.gz
rent-in-london-daf0cbf0df354753382b43c5ca21275a4722761a.tar.lz
rent-in-london-daf0cbf0df354753382b43c5ca21275a4722761a.zip
Add date comparison predicates.
* rent.scm (make-date-comparer, date<=?, date>=?): New functions.
-rw-r--r--rent.scm13
1 files changed, 13 insertions, 0 deletions
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