From 923faa0e845fb38b74d8436afcfbdc33e2551c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Sat, 13 May 2023 17:27:50 +0200 Subject: [PATCH] Document new cal-day. --- doc/calendar.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/doc/calendar.md b/doc/calendar.md index 0895dc3..bab5a64 100644 --- a/doc/calendar.md +++ b/doc/calendar.md @@ -22,6 +22,8 @@ with calendar dates - mostly with month granularity. ### Month + (import cal-month) + Module for handling months algebra to be used in period construction and matching. @@ -136,6 +138,8 @@ Returns a new valid month that comes ```n``` months after ```m```. If ### Period + (import cal-period) + This module implements simple calendar period handling with month granularity. The period contains fields ```since``` which is the first month of the period and ```before``` which is the first month just @@ -261,3 +265,71 @@ If ```v``` is a valid month, returns it unchanged. If it is a day, uses ```cal-day->month``` for conversion with given ```stop?``` as second argument. +### Day + + (import cal-day) + +This module encapsulates date storage with daily granularity. + + (make-cal-day y m d) + +* ```y``` - valid year (1000-9999) +* ```m``` - valid month number (1-12) +* ```d``` - valid day number (1-31) + +Construct a new cal-day structure representing a single calendar day. + + (cal-day? v) + +* ```v``` - any value + +Return ```#t``` if given value is a cal-day structure and it +represents a valid day, ```#f``` otherwise. + + (cal-day-year d) + +* ```d``` - valid cal-day structure + +Returns the year field of the structure. + + (cal-day-month d) + +* ```d``` - valid cal-day structure + +Returns the month field of the structure. + + (cal-day-day d) + +* ```d``` - valid cal-day structure + +Returns the day field of the structure. + + (cal-day->month d [stop?]) + +* ```d``` - a valid cal-day structure +* ```stop?``` - if ```#t```, conversion for period end + +Converts given cal-day to cal-month. If ```stop?``` is ```#f```, it +just strips the day number. Otherwise it converts the day to the same +month only if it is the first day of the month. It converts to the +next calendar month otherwise. + + (cal-day->string d) + +* ```d``` - a valid cal-day structure + +Converts given day into "YYYY-MM-DD" ISO string representation. + + (string->cal-day s) + +* ```s``` - a string containing "YYYY-MM-DD" ISO date + +Parses the string and returns a valid cal-day structure. + + (parse-cal-day/month s) + +* ```s``` - a string with ISO date with optional day part + +Tries parsing the string as cal-day and returns the result upon +success. Upon failure, parses the string as cal-month. +