summaryrefslogtreecommitdiff
path: root/util.scm
diff options
context:
space:
mode:
authorMatthew Fennell <matthew@fennell.dev>2026-04-16 16:24:05 +0100
committerMatthew Fennell <matthew@fennell.dev>2026-04-16 18:34:46 +0100
commit635960c4a470bbbd0f25120bdc65fa1b060f5b03 (patch)
tree625c636637f15ff43992a8b2e1914c33189e0e15 /util.scm
parent7770aa9aa15f35997b75a0da961ca778af542557 (diff)
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".
Diffstat (limited to 'util.scm')
-rw-r--r--util.scm7
1 files 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))