<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
> Does anyone know about a higher-level library for manipulating dates, and performing arithmetic comparisons and operations?<br>
<br>
</div>Dates are harder than they look. </blockquote><div><br></div><div>I absolutely agree with this remark!</div><div>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.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>
<br>
#lang racket<br>
<br>
(define DAY-SECONDS 86400)<br>
<br>
;; ALL DATES IN SECONDS:<br>
(define d (find-seconds seconds minutes hours day month year))<br>
(define d+1 (+ d (* 1 DAY-SECONDS)))<br>
(define d+2 (+ d (* 2 DAY-SECONDS)))<br>
(define d+3 (+ d (* 3 DAY-SECONDS)))<br>
<br>
;;And then do a comparison, like<br>
<div class=""><br>
(let ([now (current-seconds)])<br>
</div> (cond [(< now d) "on time!"]<br>
[(< now d+1) "one day late!"]<br>
[(< now d+2) "two days late!"]))<br></blockquote><div><br></div><div>Thanks, I will implement it this way!</div><div> -- </div></div>Ismael<br>
</div></div>