diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-06 19:08:59 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-13 00:14:55 +0200 |
commit | 59f6fc205b19f0cd2253adb7c656c4eda904a52e (patch) | |
tree | 2390a02195fdae3d79aa2b39d39e134c93871e3c /module/vcalendar/recurrence/generate.scm | |
parent | Rework how attributes and properties are accessed. (diff) | |
download | calp-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 '')
-rw-r--r-- | module/vcalendar/recurrence/generate.scm | 41 |
1 files changed, 31 insertions, 10 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)))) |