From a0a7e5accc4dc050057ecd99a9c741a65bd7ec5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Mar 2019 21:26:34 +0100 Subject: Add date-add to srfi srfi-19 util. --- srfi/srfi-19/util.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'srfi') diff --git a/srfi/srfi-19/util.scm b/srfi/srfi-19/util.scm index 777f39f2..a020ae55 100644 --- a/srfi/srfi-19/util.scm +++ b/srfi/srfi-19/util.scm @@ -5,7 +5,9 @@ #:export (copy-date drop-time! drop-time localize-date - date-today?)) + date-today? + seconds minutes hours days weeks + date-add)) (define (copy-date date) "Returns a copy of the given date structure" @@ -53,3 +55,13 @@ transposed to the current timezone. Current timezone gotten from (1+ (day then))) (and (%date<=? now input-date) (%date<=? input-date then)))) + +(define seconds 1) +(define minutes 60) +(define hours (* 60 minutes)) +(define days (* 24 hours)) +(define weeks (* 7 days)) + +(define (date-add date amount unit) + (time-utc->date (add-duration (date->time-utc date) + (make-time time-duration 0 (* amount unit))))) -- cgit v1.2.3