From c00a34a5ff3aaf7fdba105f0c932cd4708b8dc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 13 May 2020 02:22:59 +0200 Subject: Add all-wday-in-year. --- module/datetime/util.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'module') diff --git a/module/datetime/util.scm b/module/datetime/util.scm index 37be3b29..ad0944f3 100644 --- a/module/datetime/util.scm +++ b/module/datetime/util.scm @@ -353,6 +353,13 @@ (lambda (x) (<= sun x sat))) +;; TODO normalize if functions floor their arguments or not. +;; The argument for flooring is that it allows us to only bother with +;; the higher components we care about. +;; The argument against would be if we want to start from the middle +;; of a time span. + + ;; Returns the first instance of the given week-day in the given month. ;; @example ;; (find-first-week-day mon #2020-04-10) @@ -371,3 +378,10 @@ (stream-take-while (lambda (d) (= (month d) (month month-date))) (week-stream (find-first-week-day wday month-date))))) + + +(define-public (all-wday-in-year wday year-date) + (stream->list + (stream-take-while + (lambda (d) (= (year d) (year year-date))) + (week-stream (find-first-week-day wday year-date))))) -- cgit v1.2.3