diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-20 01:26:08 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-20 01:26:08 +0100 |
commit | ad6a6bc6027f36f505a227bc73a0c3b720f47c87 (patch) | |
tree | 730d9101ad366587c311e41efe9955d3cd94c34c /module/vcomponent/datetime.scm | |
parent | Add print-and-return macro. (diff) | |
download | calp-ad6a6bc6027f36f505a227bc73a0c3b720f47c87.tar.gz calp-ad6a6bc6027f36f505a227bc73a0c3b720f47c87.tar.xz |
Start work on better wide html renderer.
Diffstat (limited to 'module/vcomponent/datetime.scm')
-rw-r--r-- | module/vcomponent/datetime.scm | 16 |
1 files changed, 13 insertions, 3 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}. |