aboutsummaryrefslogtreecommitdiff
path: root/srfi
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-08 13:14:34 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-08 13:14:34 +0100
commite7c471cb50bf92debc6e28ef5e45d0c5e4b3da3c (patch)
treec6f59fc9464d5c9ea704c1c05a6b6f57be13bd2f /srfi
parentGot DAILY repeating event! (diff)
downloadcalp-e7c471cb50bf92debc6e28ef5e45d0c5e4b3da3c.tar.gz
calp-e7c471cb50bf92debc6e28ef5e45d0c5e4b3da3c.tar.xz
Made DTSTART have <time> instead of <date> type.
Diffstat (limited to 'srfi')
-rw-r--r--srfi/srfi-19/util.scm21
1 files changed, 20 insertions, 1 deletions
diff --git a/srfi/srfi-19/util.scm b/srfi/srfi-19/util.scm
index a020ae55..ab951ea4 100644
--- a/srfi/srfi-19/util.scm
+++ b/srfi/srfi-19/util.scm
@@ -7,8 +7,11 @@
localize-date
date-today?
seconds minutes hours days weeks
- date-add))
+ date-add
+ time-add
+ time->string))
+#;
(define (copy-date date)
"Returns a copy of the given date structure"
(let* ((date-type (@@ (srfi srfi-19) date))
@@ -36,10 +39,12 @@ attribute set to 0."
((date-nanosecond) 0)))
+#;
(define (%date<=? a b)
(time<=? (date->time-utc a)
(date->time-utc b)))
+#;
(define (localize-date date)
"Returns a <date> object representing the same datetime as `date`, but
transposed to the current timezone. Current timezone gotten from
@@ -47,6 +52,13 @@ transposed to the current timezone. Current timezone gotten from
(time-utc->date (date->time-utc date)
(date-zone-offset (current-date))))
+(define (today? time)
+ (let* ((now (current-date))
+ (then (add-duration time (make-time time-difference 0 (* 24 3600)))))
+ (and (time<=? time now)
+ (time<=? now then))))
+
+ #;
(define (date-today? input-date)
(let* ((date (current-date))
(now (drop-time date))
@@ -62,6 +74,13 @@ transposed to the current timezone. Current timezone gotten from
(define days (* 24 hours))
(define weeks (* 7 days))
+(define (time-add time amount unit)
+ (add-duration time (make-time time-duration 0 (* amount unit))))
+
+#;
(define (date-add date amount unit)
(time-utc->date (add-duration (date->time-utc date)
(make-time time-duration 0 (* amount unit)))))
+
+(define* (time->string time #:optional (format "~c"))
+ (date->string (time-utc->date time) format))