From aa6a9ac705a45f3b4da4085f1439a73ada83e7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Mon, 22 May 2023 20:25:33 +0200 Subject: [PATCH] Document new cal-day procedures and add more tests. --- doc/calendar.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ src/cal-day.scm | 18 ++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/doc/calendar.md b/doc/calendar.md index b93998c..f30ef3f 100644 --- a/doc/calendar.md +++ b/doc/calendar.md @@ -333,6 +333,56 @@ Parses the string and returns a valid cal-day structure. Tries parsing the string as cal-day and returns the result upon success. Upon failure, parses the string as cal-month. + (cal-day=? a b) + +* ```a``` - a cal-day value +* ```b``` - a cal-day value + +Returns ```#t``` if ```a``` respresents the same date as ```b``` in +calendar. + + (cal-day=? a b) + +* ```a``` - a cal-day value +* ```b``` - a cal-day value + +Returns ```#t``` if ```a``` comes after or is the same date as ```b``` +in calendar. + + (cal-day>? a b) + +Returns ```#t``` if ```a``` comes after ```b``` in calendar. + + (cal-day/monthstring v) + +* ```v``` - a cal-day or cal-month value + +Returns appropriate string representation of given value. + ### Format (import cal-format) diff --git a/src/cal-day.scm b/src/cal-day.scm index 8e6c40f..1b236c3 100644 --- a/src/cal-day.scm +++ b/src/cal-day.scm @@ -255,6 +255,24 @@ (cal-day? (parse-cal-day/month "2023-05-11"))) (test-true parse-cal-day/month (cal-month? (parse-cal-day/month "2023-05"))) + (test-true cal-day/monthstring + (cal-day/month->string (make-cal-day 2023 5 22)) + "2023-05-22") + (test-equal? cal-day/month->string + (cal-day/month->string (make-cal-month 2023 5)) + "2023-05") )) )