aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-05-19 22:29:03 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-05-19 22:29:03 +0200
commit162649858bba96ae17eb73f5ca0833df5843f2a9 (patch)
tree0497abf81ff2d0f5d83d85735a2da0da2c45ab4a
parentRemove leap and expiry from zic. (diff)
downloadcalp-162649858bba96ae17eb73f5ca0833df5843f2a9.tar.gz
calp-162649858bba96ae17eb73f5ca0833df5843f2a9.tar.xz
date=, datetime=, time= any number of arguments.
-rw-r--r--module/datetime.scm36
-rw-r--r--module/vcomponent/datetime.scm15
2 files changed, 27 insertions, 24 deletions
diff --git a/module/datetime.scm b/module/datetime.scm
index b8b515fc..3bbb48a9 100644
--- a/module/datetime.scm
+++ b/module/datetime.scm
@@ -208,19 +208,29 @@
;; 2020-02-00 + 0-0- (40 - 31) ;
;; 2020-02-09
-(define-public (date= a b)
- (and (= (year a) (year b))
- (= (month a) (month b))
- (= (day a) (day b))))
-
-(define-public (time= a b)
- (and (= (hour a) (hour b))
- (= (minute a) (minute b))
- (= (second a) (second b))))
-
-(define-public (datetime= a b)
- (and (date= (get-date a) (get-date b))
- (time= (get-time% a) (get-time% b))))
+(define-public (date= . args)
+ (reduce (lambda (a b)
+ (and (= (year a) (year b))
+ (= (month a) (month b))
+ (= (day a) (day b))
+ ;; return object
+ a))
+ #t args))
+
+(define-public (time= . args)
+ (reduce (lambda (a b)
+ (and (= (hour a) (hour b))
+ (= (minute a) (minute b))
+ (= (second a) (second b))
+ a))
+ #t args))
+
+(define-public (datetime= . args)
+ (reduce (lambda (a b)
+ (and (date= (get-date a) (get-date b))
+ (time= (get-time% a) (get-time% b))
+ a))
+ #t args))
(define-many define-public
(date=?) date=
diff --git a/module/vcomponent/datetime.scm b/module/vcomponent/datetime.scm
index 68909809..fabe3978 100644
--- a/module/vcomponent/datetime.scm
+++ b/module/vcomponent/datetime.scm
@@ -75,22 +75,15 @@ Event must have the DTSTART and DTEND attribute set."
;; 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 date e)
- ;; TODO date= > 2 elements
(let ((start (attr e 'DTSTART))
(end (attr e 'DTEND)))
- (cond [(and (date= (as-date start)
- (as-date end))
- (date= (as-date start)
- date))
- (time- (as-time end)
- (as-time start))]
+ (cond [(date= date (as-date start) (as-date end))
+ (time- (as-time end) (as-time start))]
;; Starts today, end in future day
- [(date= (as-date start)
- date)
+ [(date= date (as-date start))
(time- #24:00:00 (as-time start))]
;; Ends today, start earlier day
- [(date= (as-date end)
- date)
+ [(date= date (as-date end))
(as-time end)]
;; start earlier date, end later date
[else #24:00:00])))