aboutsummaryrefslogtreecommitdiff
path: root/module/test.scm
blob: 10c6c1a12ac425e53f97f4ddff1aea9351ff67cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/guile -s
!#

(add-to-load-path (dirname (current-filename)))

(use-modules (rnrs base)                ; assert
             (srfi srfi-1)
             (srfi srfi-19)
             (srfi srfi-19 util)
             (srfi srfi-41)
             (vcalendar)
             (vcalendar output)
             (vcalendar recur))

(define cal (make-vcomponent "../testcal/repeating-event.ics"))

(define ev (car (children cal 'VEVENT)))

(define ev-copy (copy-vcomponent ev))

(assert (equal? (children ev)
                (children ev-copy)))

(define (display-timespan ev)
  (format #t "~a ~a ~a -- ~a~%"
          (attr ev 'NEW_ATTR)
          (attr ev 'N)
          (time->string (attr ev "DTSTART"))
          (time->string (attr ev "DTEND"))))

(display (attr ev 'N)) (newline)
(display-timespan ev)
(display (attr ev 'NEW_ATTR)) (newline)
(newline)
(define strm (generate-recurrence-set ev))
(display (attr ev 'RRULE)) (newline)

(if #f
    (begin
      (stream-for-each display-timespan (stream-take 20 strm))

      (newline)

      ;; (define strm (generate-recurrence-set ev))
      (display (attr ev 'RRULE)) (newline)

      ;; This makes the amount of events lookad at before have the same DTSTART,
      ;; which is the last from that set. The one's after that however are fine.
      (stream-for-each display-timespan (stream-take 40 strm))
      (newline)
      ;; This makes all the DTSTART be the last dtstart
      ;; (for-each display-timespan (stream->list (stream-take 20 strm)))

;;; I believe that I might have something to do with the stream's cache.

      (newline)

      (display-timespan ev)
      (display (attr ev 'NEW_ATTR))
      (newline))
    (begin
      ;; These two acts as one large unit.
      ;; Something modifies the initial ev even though it shouldn't
      (display-timespan ev)
      (stream-for-each
       display-timespan
       (stream-take 20 (generate-recurrence-set (copy-vcomponent ev))))
      (newline)
      (display-timespan ev)
      (newline)
      (stream-for-each
       display-timespan
       (stream-take 40 (generate-recurrence-set (copy-vcomponent ev))))
      (newline)
      (display-timespan ev)
      ))