From 93d909411a3a26cf2e65ecc87deff2bede4777f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 25 Apr 2020 23:12:15 +0200 Subject: Renormalize some dt's to local time, solving owerflow. Previously, if a DTEND = 01:00+02:00, but was given in UTC (23:00Z) then the fact that DTEND was in different dates lead to some problems. --- module/output/html.scm | 4 ++-- module/vcomponent/datetime.scm | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/module/output/html.scm b/module/output/html.scm index 5e09d30f..70c3b8a9 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -186,12 +186,12 @@ "unknown")) ,(when (and (attr ev 'PARTSTAT) (string= "TENTATIVE" (attr ev 'PARTSTAT))) " tentative") - ,(when (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])) + (let ((start (get-datetime (attr e 'DTSTART))) + (end (get-datetime (attr e 'DTEND)))) + (cond [(and (date= (as-date start) + (as-date end)) + (date= (as-date start) + date)) + (time- (as-time end) + (as-time start))] + ;; Starts today, end in future day + [(date= (as-date start) + date) + (time- #24:00:00 (as-time start))] + ;; Ends today, start earlier day + [(date= (as-date end) + date) + (as-time end)] + ;; start earlier date, end later date + [else #24:00:00]))) ;; 22:00 - 03:00 -- cgit v1.2.3