aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-20 01:26:08 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-20 01:26:08 +0100
commitad6a6bc6027f36f505a227bc73a0c3b720f47c87 (patch)
tree730d9101ad366587c311e41efe9955d3cd94c34c /module/vcomponent
parentAdd print-and-return macro. (diff)
downloadcalp-ad6a6bc6027f36f505a227bc73a0c3b720f47c87.tar.gz
calp-ad6a6bc6027f36f505a227bc73a0c3b720f47c87.tar.xz
Start work on better wide html renderer.
Diffstat (limited to 'module/vcomponent')
-rw-r--r--module/vcomponent/datetime.scm16
-rw-r--r--module/vcomponent/recurrence/generate.scm16
2 files changed, 20 insertions, 12 deletions
diff --git a/module/vcomponent/datetime.scm b/module/vcomponent/datetime.scm
index 27153cea..ffde1e6e 100644
--- a/module/vcomponent/datetime.scm
+++ b/module/vcomponent/datetime.scm
@@ -46,9 +46,19 @@ Event must have the DTSTART and DTEND attribute set."
;; Returns length of the event @var{e}, as a time-duration object.
(define-public (event-length e)
- (time-
- (attr e 'DTEND)
- (attr e 'DTSTART)))
+ (if (not (attr e 'DTEND))
+ (datetime date:
+ (if (date? (attr e 'DTSTART))
+ #24:00:00
+ #01:00:00))
+ (let ((ret (datetime-difference (as-datetime (attr e 'DTEND))
+ (as-datetime (attr e 'DTSTART)))))
+ (format (current-error-port) "ret = ~a~%" ret)
+ ret)))
+
+(define-public (event-length/clamped start-date end-date e)
+ (datetime-difference (datetime-min (datetime date: end-date) (as-datetime (attr e 'DTEND)))
+ (datetime-max (datetime date: start-date) (as-datetime (attr e 'DTSTART)))))
;; Returns the length of the part of @var{e} which is within the day
;; starting at the time @var{start-of-day}.
diff --git a/module/vcomponent/recurrence/generate.scm b/module/vcomponent/recurrence/generate.scm
index f786a586..ba6257f8 100644
--- a/module/vcomponent/recurrence/generate.scm
+++ b/module/vcomponent/recurrence/generate.scm
@@ -81,11 +81,7 @@
(change (attr e 'X-HNH-DURATION)))
(when end
(set! (attr e 'DTEND)
- ((cond
- [(date? end) date+ ]
- [(datetime? end) datetime+]
- [else (error "End neither date nor datetime ~a" end)])
- start change))))))
+ (datetime+ (as-datetime start) (datetime time: change)))))))
e))
@@ -159,8 +155,9 @@
;; The value type of dtstart and dtend must be the same
;; according to RFC 5545 3.8.2.2 (Date-Time End).
(if (date? end)
- (date-difference end (attr event 'DTSTART))
- (datetime-difference end (attr event 'DTSTART))))]))
+ (time second: (print-and-return (date-difference end (attr event 'DTSTART))))
+ (time second: (print-and-return (datetime-difference end (attr event 'DTSTART))))))]))
+ (format (current-error-port) "duration = ~a~%" (attr event 'X-HNH-DURATION))
(if (attr event "RRULE")
(recur-event-stream event (parse-recurrence-rule
(attr event "RRULE")
@@ -171,8 +168,9 @@
stream-null))))
(lambda (err . args)
(format (current-error-port)
- "\x1b[0;31mError\x1b[m while parsing recurrence rule (ignoring and continuing)~%~a ~a~%~a~%~%"
+ "\x1b[0;31mError\x1b[m while parsing recurrence rule (ignoring and continuing)~%~a ~s~%~a~%~%"
err args
(attr event 'X-HNH-FILENAME))
(stream ; event
- ))))
+ )
+ )))