diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-11-04 16:51:30 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-11-04 16:51:30 +0100 |
commit | 9c908b0c745f56b887f40ff4a37f07185561b95f (patch) | |
tree | 07bb5ba671f9e965b02b3474c4f27e798f463679 /module | |
parent | Remove commented code from parse-calendar. (diff) | |
download | calp-9c908b0c745f56b887f40ff4a37f07185561b95f.tar.gz calp-9c908b0c745f56b887f40ff4a37f07185561b95f.tar.xz |
Remove (vcomponent timezone).
Diffstat (limited to '')
-rw-r--r-- | module/vcomponent.scm | 1 | ||||
-rw-r--r-- | module/vcomponent/recurrence/generate.scm | 1 | ||||
-rw-r--r-- | module/vcomponent/timezone.scm | 96 |
3 files changed, 0 insertions, 98 deletions
diff --git a/module/vcomponent.scm b/module/vcomponent.scm index 18a96e7a..1bffe847 100644 --- a/module/vcomponent.scm +++ b/module/vcomponent.scm @@ -1,7 +1,6 @@ (define-module (vcomponent) #:use-module (vcomponent datetime) #:use-module (vcomponent recurrence) - #:use-module (vcomponent timezone) #:use-module (vcomponent base) #:use-module (vcomponent parse) #:use-module (srfi srfi-1) diff --git a/module/vcomponent/recurrence/generate.scm b/module/vcomponent/recurrence/generate.scm index ea17b0e0..50ce83e5 100644 --- a/module/vcomponent/recurrence/generate.scm +++ b/module/vcomponent/recurrence/generate.scm @@ -8,7 +8,6 @@ #:use-module (util) #:use-module (vcomponent base) - #:use-module (vcomponent timezone) #:use-module (vcomponent recurrence internal) #:use-module (vcomponent recurrence parse) diff --git a/module/vcomponent/timezone.scm b/module/vcomponent/timezone.scm deleted file mode 100644 index ed3bef6b..00000000 --- a/module/vcomponent/timezone.scm +++ /dev/null @@ -1,96 +0,0 @@ -(define-module (vcomponent timezone) - :use-module (vcomponent base) - :use-module ((srfi srfi-1) :select (find)) - :use-module (srfi srfi-19) - :use-module (srfi srfi-19 util) - :use-module (srfi srfi-41) - :use-module (srfi srfi-41 util) - :use-module (util) - :use-module ((vcomponent recurrence generate) :select (generate-recurrence-set)) - :use-module ((vcomponent datetime) :select (ev-time<?)) - ) - -;;@begin exampe -;; <VTIMEZONE> :: "#<vcomponent 558c5da80fc0>" -;; TZID: Europe/Stockholm -;; X-LIC-LOCATION: Europe/Stockholm -;; : <DAYLIGHT> :: "#<vcomponent 558c5e11e7c0>" -;; : RRULE: FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU -;; : DTSTART: 19700329T020000 -;; : TZNAME: CEST -;; : TZOFFSETTO: +0200 -;; : TZOFFSETFROM: +0100 -;; : <STANDARD> :: "#<vcomponent 558c5e11e7e0>" -;; : RRULE: FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU -;; : DTSTART: 19701025T030000 -;; : TZNAME: CET -;; : TZOFFSETTO: +0100 -;; : TZOFFSETFROM: +0200 -;; @end example - -;; Given a tz stream of length 2, extrapolates when the next timezone -;; change aught to be. -;; Currently it does so by taking the first time zone, and adding one -;; year. This kind of works. -;; Previously it took the difference between element 2 and 1, and added -;; that to the start of the secound time zone. This was even more wrong. -;; TODO? set remaining properties, and type of the newly created component. -(define (extrapolate-tz-stream strm) - (let ((nevent (copy-vcomponent (stream-car strm)))) - (set! (attr nevent 'DTSTART) - (date->time-utc - (set (date-year - (time-utc->date (attr nevent 'DTSTART))) - = (+ 1)))) - (stream-append strm (stream nevent)))) - -;; The RFC requires that at least one DAYLIGHT or STANDARD component is present. -;; Any number of both can be present. This should handle all these cases well, -;; as long as noone has multiple overlapping timezones, which depend on some -;; further condition. That feels like something that should be impossible, but -;; this is (human) time we are talking about. -(define-public (make-tz-set tz) - (let ((strm (interleave-streams - ev-time<? - ;; { DAYLIGHT, STANDARD } - (map generate-recurrence-set (children tz))))) - - (cond [(stream-null? strm) stream-null] - - [(stream-null? (stream-drop 2 strm)) - (let ((strm (extrapolate-tz-stream strm))) - (stream-zip strm (stream-cdr strm)))] - - [else (stream-zip strm (stream-cdr strm))]))) - -;; str ::= ±[0-9]{4} -;; str → int seconds -(define (parse-offset str) - (let* (((± h1 h0 m1 m0) (string->list str))) - ((primitive-eval (symbol ±)) - (+ (* 60 (string->number (string m1 m0))) - (* 60 60 (string->number (string h1 h0))))))) - -;; Finds the VTIMEZONE with id @var{tzid} in calendar. -;; Crashes on error. -(define (find-tz cal tzid) - (let ((ret (find (lambda (tz) (string=? tzid (attr tz 'TZID))) - (filter (lambda (o) (eq? 'VTIMEZONE (type o))) - (children cal))))) - ret)) - -;; Takes a VEVENT. -;; Assumes that DTSTART has a TZID property, and that that TZID is available as -;; a direct child of the parent of @var{ev}. -(define-public (get-tz-offset ev) - (let ((ret (stream-find - (lambda (z) - (let* (((start end) (map (extract 'DTSTART) z))) - (and (time<=? start (attr ev 'DTSTART)) - (time<? (attr ev 'DTSTART) end)))) - (attr (find-tz (parent ev) - (car (prop (attr* ev 'DTSTART) 'TZID))) - 'X-HNH-TZSET)))) - (if (not ret) - 0 (parse-offset (attr (car ret) 'TZOFFSETTO))))) - |