aboutsummaryrefslogtreecommitdiff
path: root/module/vcalendar/recurrence
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-06 19:08:59 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-13 00:14:55 +0200
commit59f6fc205b19f0cd2253adb7c656c4eda904a52e (patch)
tree2390a02195fdae3d79aa2b39d39e134c93871e3c /module/vcalendar/recurrence
parentRework how attributes and properties are accessed. (diff)
downloadcalp-59f6fc205b19f0cd2253adb7c656c4eda904a52e.tar.gz
calp-59f6fc205b19f0cd2253adb7c656c4eda904a52e.tar.xz
Add earlier work on timezones.
Add earlier work on timezones, with a few inline modifications. This is really to big of a commit. But we are so far from a stable release that it should be fine. The current version seems to eager, and recalculates to many times. This will soon be fixed in a future version.
Diffstat (limited to 'module/vcalendar/recurrence')
-rw-r--r--module/vcalendar/recurrence/generate.scm41
-rw-r--r--module/vcalendar/recurrence/parse.scm4
2 files changed, 34 insertions, 11 deletions
diff --git a/module/vcalendar/recurrence/generate.scm b/module/vcalendar/recurrence/generate.scm
index f585843f..2a5cfc91 100644
--- a/module/vcalendar/recurrence/generate.scm
+++ b/module/vcalendar/recurrence/generate.scm
@@ -1,6 +1,7 @@
(define-module (vcalendar recurrence generate)
#:use-module (srfi srfi-19) ; Datetime
#:use-module (srfi srfi-19 util)
+ #:use-module (srfi srfi-19 setters)
#:use-module (srfi srfi-26) ; Cut
#:use-module (srfi srfi-41) ; Streams
#:use-module (ice-9 match)
@@ -54,11 +55,20 @@
(seconds-in (freq r)))))))
((memv (freq r) '(MONTHLY YEARLY))
- #f ; Hur fasen beräkrnar man det här!!!!
- ))
+ (let ((sdate (time-utc->date (attr e 'DTSTART))))
+ (case (freq r)
+ ((MONTHLY) (mod! (month sdate) (cut + <> (interval r))))
+ ((YEARLY) (mod! (year sdate) (cut + <> (interval r)))))
+ (set! (attr e 'DTSTART)
+ (date->time-utc sdate))))
- (set! (attr e 'DTEND)
- (add-duration (attr e 'DTSTART) (attr e 'DURATION)))
+ ;; TODO
+ ;; All the BY... fields
+ )
+
+ (when (attr e 'DTEND)
+ (set! (attr e 'DTEND)
+ (add-duration (attr e 'DTSTART) (attr e 'DURATION))))
;; Return
e))
@@ -102,9 +112,20 @@
(define (generate-recurrence-set event)
- (unless (attr event "DURATION")
- (set! (attr event "DURATION")
- (time-difference
- (attr event "DTEND")
- (attr event "DTSTART"))))
- (recur-event-stream event (parse-recurrence-rule (attr event "RRULE"))))
+ ;; TODO DURATION might be used for something else, check applicable types
+ ;; TODO Far from all events have DTEND
+ ;; VTIMEZONE's always lack it.
+ (if (not (attr event 'RRULE))
+ (stream event)
+ (begin
+ (when (and (attr event 'DTEND)
+ (not (attr event 'DURATION)))
+ (set! (attr event "DURATION")
+ (time-difference
+ (attr event "DTEND")
+ (attr event "DTSTART"))))
+ (if (attr event "RRULE")
+ (recur-event-stream event (parse-recurrence-rule (attr event "RRULE")))
+ ;; TODO some events STANDARD and DAYLIGT doesn't have RRULE's, but rather
+ ;; just mention the current part. Handle this
+ stream-null))))
diff --git a/module/vcalendar/recurrence/parse.scm b/module/vcalendar/recurrence/parse.scm
index ad8f06c3..de5d7e7c 100644
--- a/module/vcalendar/recurrence/parse.scm
+++ b/module/vcalendar/recurrence/parse.scm
@@ -87,7 +87,9 @@
(let* (((key val) kv)
;; Lazy fields for the poor man.
(symb (lambda () (string->symbol val)))
- (date (lambda () (parse-datetime val)))
+ (date (lambda ()
+ (let* ((date type (parse-datetime val)))
+ (date->time-utc date))))
(days (lambda () (map parse-day-spec (string-split val #\,))))
(num (lambda () (string->number val)))
(nums (lambda () (string->number-list val #\,))))