From cbd17399e35dec45229479090e40252d43d0a5ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Thu, 11 May 2023 16:27:39 +0200 Subject: [PATCH] Prepare for universal day/month handling in queries. --- src/Makefile | 4 ++-- src/cal-period.scm | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index aad54f1..e85d290 100644 --- a/src/Makefile +++ b/src/Makefile @@ -364,8 +364,8 @@ CAL-MONTH-SOURCES=cal-month.scm util-tag.import.scm \ cal-month.o: cal-month.import.scm cal-month.import.scm: $(CAL-MONTH-SOURCES) -CAL-PERIOD-SOURCES=cal-period.scm cal-month.import.scm \ - testing.import.scm util-tag.import.scm +CAL-PERIOD-SOURCES=cal-period.scm cal-month.import.scm \ + testing.import.scm util-tag.import.scm cal-day.import.scm cal-period.o: cal-period.import.scm cal-period.import.scm: $(CAL-PERIOD-SOURCES) diff --git a/src/cal-period.scm b/src/cal-period.scm index d51e745..c27e23a 100644 --- a/src/cal-period.scm +++ b/src/cal-period.scm @@ -49,6 +49,8 @@ make-cal-period-lookup-table lookup-by-cal-period + + cal-ensure-month cal-period-tests! ) @@ -62,7 +64,8 @@ (chicken string) cal-month testing - util-tag) + util-tag + cal-day) ;; Type tag (define TAG-CAL-PERIOD (make-tag CAL-PERIOD)) @@ -219,6 +222,12 @@ (cdar lst) (loop (cdr lst)))))) + ;; Wrapper that accepts either day or month and returns testable month + (define (cal-ensure-month v . stop?s) + (if (cal-month? v) + v + (apply cal-day->month v stop?s))) + ;; Performs self-tests of the period module. (define (cal-period-tests!) (run-tests