aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rent.scm13
1 files changed, 11 insertions, 2 deletions
diff --git a/rent.scm b/rent.scm
index 832746b..08e8dde 100644
--- a/rent.scm
+++ b/rent.scm
@@ -19,6 +19,7 @@
(rnrs io ports)
(srfi srfi-1)
(srfi srfi-9)
+ (srfi srfi-19)
(srfi srfi-26)
(srfi srfi-71)
(srfi srfi-43)
@@ -147,6 +148,12 @@ somewhere in @var{html}, a string."
@code{#f} if @var{n} is 0 and @code{#t} otherwise."
(not (zero? n)))
+(define (date+ date days)
+ "Add @var{days} number of days to @var{date}."
+ (time-utc->date
+ (add-duration (date->time-utc date)
+ (make-time time-duration 0 (* days 24 60 60)))))
+
(define (all-houses)
"Return a list of all houses on the OpenRent index page."
(let ((html (bytevector->string (http-get* %openrent-index-url
@@ -192,7 +199,9 @@ somewhere in @var{html}, a string."
(extract-variable html "bills"))
(map to-boolean
(extract-variable html "fireplaces"))
- (extract-variable html "availableFrom")
+ (map (lambda (offset)
+ (date+ (current-date) offset))
+ (extract-variable html "availableFrom"))
(extract-variable html "minimumTenancy")
(map string->number
(extract-variable html "PROPERTYLISTCOMMUTEORDISTANCE")))))
@@ -227,7 +236,7 @@ somewhere in @var{html}, a string."
;; If not cached or cache is stale, query and cache.
(when (or (not (file-exists? cache-file))
(and cache-live-time
- (> (current-time)
+ (> (time-second (current-time))
(+ (stat:mtime (stat cache-file))
cache-live-time))))
(call-with-atomic-output-file cache-file