From 635960c4a470bbbd0f25120bdc65fa1b060f5b03 Mon Sep 17 00:00:00 2001 From: Matthew Fennell Date: Thu, 16 Apr 2026 16:24:05 +0100 Subject: Extract 10pm-adjusted-date to a function This is useful in other functions as well, as it's essentially "better.org.uk's definition of the current date regarding what bookings are available". --- util.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util.scm b/util.scm index 495bcfd..a550427 100644 --- a/util.scm +++ b/util.scm @@ -89,10 +89,13 @@ (date-hour date) 0 0 0 0)) +(define (10pm-adjusted-date date) + (let ((date-offset (if (> (date-hour date) 22) 1 0))) + (date+ (current-date) date-offset))) + (define (this day-name) (log-msg 'DEBUG "Calculating next " day-name) - (let* ((date-offset (if (> (date-hour (current-date)) 22) 1 0)) - (current-date (date+ (current-date) date-offset)) + (let* ((current-date (10pm-adjusted-date (current-date))) (current-week-day (date-week-day current-date)) (target-week-day (day-name->week-day day-name)) (days-ahead (mod (- target-week-day current-week-day) 7)) -- cgit v1.2.3