aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/group.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-21 16:17:28 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-22 22:58:30 +0100
commitd00fea566004e67161ee45246b239fff5d416b0e (patch)
tree5641c0c0d0e78b046b6045ed2440512f12259560 /module/vcomponent/group.scm
parentComplete rewrite of use2dot (diff)
downloadcalp-d00fea566004e67161ee45246b239fff5d416b0e.tar.gz
calp-d00fea566004e67161ee45246b239fff5d416b0e.tar.xz
Cleanup modules.
Primarly this moves all vcompenent input and output code to clearly labeled modules, instead of being spread out. At the same time it also removes a handfull of unused procedures.
Diffstat (limited to 'module/vcomponent/group.scm')
-rw-r--r--module/vcomponent/group.scm71
1 files changed, 0 insertions, 71 deletions
diff --git a/module/vcomponent/group.scm b/module/vcomponent/group.scm
deleted file mode 100644
index d23787ef..00000000
--- a/module/vcomponent/group.scm
+++ /dev/null
@@ -1,71 +0,0 @@
-(define-module (vcomponent group)
- #:use-module (vcomponent)
- #:use-module (vcomponent datetime)
- #:use-module (datetime)
- #:use-module (srfi srfi-41)
- #:use-module (srfi srfi-41 util)
- #:export (group-stream get-groups-between))
-
-;; TODO templetize this
-(define-stream (group-stream in-stream)
- (define (ein? day) (lambda (e) (event-contains? e day)))
-
- (if (stream-null? in-stream)
- stream-null
- (let loop ((days (day-stream (as-date (prop (stream-car in-stream) 'DTSTART))))
- (stream in-stream))
- (let* ((day (stream-car days))
- (tomorow (stream-car (stream-cdr days))))
-
- (let ((head (stream-take-while (ein? day) stream))
- (tail
- ;; This is a filter, instead of a stream-span together with head,
- ;; since events can span multiple days.
- ;; This starts with taking everything which end after the beginning
- ;; of tommorow, and finishes with the rest when it finds the first
- ;; object which begins tomorow (after midnight, exclusize).
- (filter-sorted-stream*
- (lambda (e) (date/-time<? tomorow
- (or (prop e 'DTEND)
- (if (date? (prop e 'DTSTART))
- (date+ (prop e 'DTSTART) (date day: 1))
- (prop e 'DTSTART)))))
- (lambda (e) (date/-time<=? tomorow (prop e 'DTSTART)))
- stream)))
-
-
- (stream-cons (cons day head)
- (loop (stream-cdr days)
- tail)))))))
-
-(define (get-groups-between groups start-date end-date)
-
- (define good-part
- (filter-sorted-stream
- (compose (in-date-range? start-date end-date)
- car)
- groups))
-
- ;; NOTE slightly ugly hack. The first element in the return of group-stream shares
- ;; it's date component with the lowest dtstart in the event set. This means that a
- ;; group set might start after our start- (and end-!) date.
- ;; To combat this I simple create a bunch of dummy groups below.
-
- (cond [(stream-null? good-part)
- (list->stream
- (map (lambda (d) (cons d stream-null))
- (date-range start-date end-date)))]
- [(car (stream-car good-part))
- (lambda (d) (date< start-date d))
- => (lambda (d)
- (stream-append
- (list->stream
- (map (lambda (d) (cons d stream-null))
- (date-range start-date
- (date- d (date day: 1)))))
- good-part))]
- [else good-part]))
-
-
-(define-public (group->event-list group)
- (stream->list (cdr group)))