diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-13 02:22:59 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-13 02:22:59 +0200 |
commit | c00a34a5ff3aaf7fdba105f0c932cd4708b8dc4b (patch) | |
tree | b5e943127444fc1f8c3e1a3720baafeaf1349a76 /module/datetime/util.scm | |
parent | Change values-map to valued-map. (diff) | |
download | calp-c00a34a5ff3aaf7fdba105f0c932cd4708b8dc4b.tar.gz calp-c00a34a5ff3aaf7fdba105f0c932cd4708b8dc4b.tar.xz |
Add all-wday-in-year.
Diffstat (limited to 'module/datetime/util.scm')
-rw-r--r-- | module/datetime/util.scm | 14 |
1 files changed, 14 insertions, 0 deletions
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))))) |