[racket] Converting a date to seconds
On 2011-07-31 6:47 AM, Mark Carter wrote:
> The alternative would be to use srfi/19, which has a usable make-date
> function, but doesn't seem to be able to convert that to seconds.
This will work, but it suffers from the problems of Unix's time_t (which
I hope aren't a problem for you, since you're interested in year
resolution?):
#lang racket
(require srfi/19)
(define (date->seconds date epoch-date)
(time-second
(time-difference (date->time-utc date)
(date->time-utc epoch-date))))
(date->seconds (current-date)
(make-date 0 0 0 0 1 1 1970 0))
It gives the same answers as time(3).
Regards,
Tony