diff options
Diffstat (limited to 'srfi')
-rw-r--r-- | srfi/srfi-19/util.scm | 21 |
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)) |