> > > > Does anyone know about a higher-level library for manipulating dates, > and performing arithmetic comparisons and operations? > > Dates are harder than they look.
I absolutely agree with this remark! Indeed this was the reason I was surprised that (it seems) there is no high-level date manipulation library, like e.g. Joda Time for Java. > In this case, for instance, I think it would be a bad idea to add to the > "day" without checking that the result is a legal date. However, in this > (and many other) instance(s), it seems like you can get nearly everything > you want simply by holding off on the "seconds->date" call. > > #lang racket > > (define DAY-SECONDS 86400) > > ;; ALL DATES IN SECONDS: > (define d (find-seconds seconds minutes hours day month year)) > (define d+1 (+ d (* 1 DAY-SECONDS))) > (define d+2 (+ d (* 2 DAY-SECONDS))) > (define d+3 (+ d (* 3 DAY-SECONDS))) > > ;;And then do a comparison, like > > (let ([now (current-seconds)]) > (cond [(< now d) "on time!"] > [(< now d+1) "one day late!"] > [(< now d+2) "two days late!"])) > Thanks, I will implement it this way! -- Ismael
____________________ Racket Users list: http://lists.racket-lang.org/users