diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 22:52:57 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 22:52:57 +0100 |
commit | e7c99e14691e768e0c3e7c54049301183ddfc32f (patch) | |
tree | d71df8a65506c6ab5c935e7ed2e25a0fd9ce5d13 /module/vcomponent | |
parent | Add date-{min,max}. (diff) | |
download | calp-e7c99e14691e768e0c3e7c54049301183ddfc32f.tar.gz calp-e7c99e14691e768e0c3e7c54049301183ddfc32f.tar.xz |
Change date{,time}-difference to hopefully sensible types.
Diffstat (limited to '')
-rw-r--r-- | module/vcomponent/datetime.scm | 16 | ||||
-rw-r--r-- | module/vcomponent/recurrence/generate.scm | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/module/vcomponent/datetime.scm b/module/vcomponent/datetime.scm index 4db9dbf1..5df4dfab 100644 --- a/module/vcomponent/datetime.scm +++ b/module/vcomponent/datetime.scm @@ -51,12 +51,20 @@ Event must have the DTSTART and DTEND attribute set." (if (date? (attr e 'DTSTART)) #24:00:00 #01:00:00)) - (datetime-difference (as-datetime (attr e 'DTEND)) - (as-datetime (attr e 'DTSTART))))) + ((if (date? (attr e 'DTSTART)) + date-difference datetime-difference) + (attr e 'DTEND) (attr e 'DTSTART)))) (define-public (event-length/clamped start-date end-date e) - (datetime-difference (datetime-min (datetime date: (date+ end-date (date day: 1))) (as-datetime (attr e 'DTEND))) - (datetime-max (datetime date: start-date) (as-datetime (attr e 'DTSTART))))) + (if (date? (attr e 'DTSTART)) + (date-difference (date-min (date+ end-date (date day: 1)) + (attr e 'DTEND)) + (date-max start-date + (attr e 'DTSTART))) + (datetime-difference (datetime-min (datetime date: (date+ end-date (date day: 1))) + (get-datetime (attr e 'DTEND))) + (datetime-max (datetime date: start-date) + (get-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 ac8a6ad8..ce64e741 100644 --- a/module/vcomponent/recurrence/generate.scm +++ b/module/vcomponent/recurrence/generate.scm @@ -78,7 +78,7 @@ (set! (attr e 'DTEND) (if (date? start) (date+ start change) - (datetime+ start (datetime time: change)))))))) + (datetime+ start change))))))) e)) @@ -153,7 +153,7 @@ ;; according to RFC 5545 3.8.2.2 (Date-Time End). (if (date? end) (date-difference end (attr event 'DTSTART)) - (time second: (datetime-difference end (attr event 'DTSTART)))))])) + (datetime-difference end (attr event 'DTSTART))))])) (if (attr event "RRULE") (recur-event-stream event (parse-recurrence-rule (attr event "RRULE") |