diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2020-02-14 00:01:25 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2020-02-14 00:01:25 +0100 |
commit | 029c2233e35a81e50154a1caedfe0041af9fb8b9 (patch) | |
tree | 4dfff42d7a13f3238e820e2aff0e178894b764d7 /module/vcomponent | |
parent | Fix date<%, similar to time<. (diff) | |
download | calp-029c2233e35a81e50154a1caedfe0041af9fb8b9.tar.gz calp-029c2233e35a81e50154a1caedfe0041af9fb8b9.tar.xz |
Fix event-length/day.
Diffstat (limited to '')
-rw-r--r-- | module/vcomponent/datetime.scm | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/module/vcomponent/datetime.scm b/module/vcomponent/datetime.scm index 765c065d..016eeaac 100644 --- a/module/vcomponent/datetime.scm +++ b/module/vcomponent/datetime.scm @@ -54,10 +54,24 @@ Event must have the DTSTART and DTEND attribute set." ;; starting at the time @var{start-of-day}. ;; currently the secund argument is a date, but should possibly be changed ;; to a datetime to allow for more explicit TZ handling? -(define-public (event-length/day e) - (time- - (time-min #00:00:00 (as-time (attr e 'DTEND))) - (time-max #24:00:00 (as-time (attr e 'DTSTART))))) +(define-public (event-length/day date e) + ;; TODO date= > 2 elements + (cond [(and (date= (as-date (attr e 'DTSTART)) + (as-date (attr e 'DTEND))) + (date= (as-date (attr e 'DTSTART)) + date)) + (time- (as-time (attr e 'DTEND)) + (as-time (attr e 'DTSTART)))] + ;; Starts today, end in future day + [(date= (as-date (attr e 'DTSTART)) + date) + (time- #24:00:00 (as-time (attr e 'DTSTART)))] + ;; Ends today, start earlier day + [(date= (as-date (attr e 'DTEND)) + date) + (as-time (attr e 'DTEND))] + ;; start earlier date, end later date + [else #24:00:00])) ;; 22:00 - 03:00 |