From: Gordon Weakliem <gweakliem@od...> - 2004-08-06 04:47:53
This may be a fairly evil thing to be doing in the first place, but I've been doing date arithmetic using SRFI-19 like so:
(require (prefix time: ("19.ss" "srfi")))
(lambda (dt n)
(time:julian-day->date (+ n (time:date->julian-day dt)) 0)))
Now, I can do something like the following:
> (define next-dt (time:current-date))
> (time:date->string next-dt)
"Thu Aug 05 22:24:58-0600 2004"
; I'm expecting to get something like "Sun Aug 08 22:24:58-0600 2004"
> (set! next-dt (date-add-days next-dt 3))
* remainder: expects type <integer> as 1st argument, given: 9827308833624167200/9; other arguments were: 1000000000
The thing is, this works using the 1.3 SRFI release, somehow, but when I got a new version of SRFI from CVS this now is broken. Any suggestions on what the right way to do this would be?
From: Anton van Straaten <anton@ap...> - 2004-08-06 05:10:29
> This may be a fairly evil thing to be doing in the first place,
> but I've been doing date arithmetic using SRFI-19 like so:
It's not SRFI-19, but FWIW, I've used something even more evil (no
guarantees, it's not being used in anything mission-critical):
;; routines to support calendar dates with no time info
(require (lib "date.ss"))
;; adds support for (make-date year month day)
(let ((sys-make-date make-date))
(if (= (length args) 3)
(seconds->date (apply find-seconds 0 0 0 (reverse args)))
(apply sys-make-date args)))))
(define (date->seconds date)
(find-seconds 0 0 0 (date-day date) (date-month date) (date-year date)))
(define (days-between first-date last-date)
(/ (- (date->seconds last-date) (date->seconds first-date)) 24 60 60))
(define (date+ date days)
(seconds->date (+ (date->seconds date) (* days 24 60 60))))
Get latest updates about Open Source Projects, Conferences and News.