aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-22 22:15:55 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-22 22:15:55 +0100
commitaa2a1e907843b7f3bc7984b32fd0344c9cf24a94 (patch)
treeef17a1f678fcf3da695d08c0cfd26f83d65a8f2b /module
parentevent-length/clapmed works marginally better. (diff)
downloadcalp-aa2a1e907843b7f3bc7984b32fd0344c9cf24a94.tar.gz
calp-aa2a1e907843b7f3bc7984b32fd0344c9cf24a94.tar.xz
Date difference once again returns dates.
Diffstat (limited to 'module')
-rw-r--r--module/datetime.scm5
-rw-r--r--module/output/html.scm9
-rw-r--r--module/vcomponent/recurrence/generate.scm6
3 files changed, 11 insertions, 9 deletions
diff --git a/module/datetime.scm b/module/datetime.scm
index 6c613c55..8df055de 100644
--- a/module/datetime.scm
+++ b/module/datetime.scm
@@ -570,8 +570,9 @@
(car (mktime (datetime->tm start)))))
(define-public (date-difference end start)
- (datetime-difference (datetime date: end)
- (datetime date: start)))
+ (date day: (/ (datetime-difference (datetime date: end)
+ (datetime date: start))
+ 86400)))
;;; Parsers for vcomponent usage
diff --git a/module/output/html.scm b/module/output/html.scm
index 4ed44587..baa2915f 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -180,8 +180,8 @@
(define (create-top-block start-date end-date ev)
- ;; TODO
- (define total-length (exact->inexact (/ (date-difference (date+ end-date (date day: 1)) start-date) 3600)))
+ ;; NOTE be vary of api changes to date-diffenence
+ (define total-length (* 24 (day (date-difference (date+ end-date (date day: 1)) start-date))))
(define style
(format #f "top:~,3f%;height:~,3f%;left:~,3f%;width:~,3f%;"
@@ -274,9 +274,8 @@
;; @end example
;; date, date → int
(define (days-between start-date end-date)
- ;; TODO do rounding better
- (inexact->exact (ceiling (1+ (exact->inexact (/ (date-difference end-date start-date)
- 86400))))))
+ ;; TODO be vary if date-difference changes again
+ (1+ (day (date-difference end-date start-date))))
;; date, date → [list date]
(define (date-range start end)
diff --git a/module/vcomponent/recurrence/generate.scm b/module/vcomponent/recurrence/generate.scm
index 42b3ca09..ac1402fa 100644
--- a/module/vcomponent/recurrence/generate.scm
+++ b/module/vcomponent/recurrence/generate.scm
@@ -81,7 +81,9 @@
(change (attr e 'X-HNH-DURATION)))
(when end
(set! (attr e 'DTEND)
- (datetime+ (as-datetime start) (datetime time: change)))))))
+ (if (date? start)
+ (date+ start change)
+ (datetime+ start (datetime time: change))))))))
e))
@@ -155,7 +157,7 @@
;; 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)
- (time second: (date-difference end (attr event 'DTSTART)))
+ (date-difference end (attr event 'DTSTART))
(time second: (datetime-difference end (attr event 'DTSTART)))))]))
(if (attr event "RRULE")
(recur-event-stream event (parse-recurrence-rule