[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] (current-seconds) returning negative values

From: Alejandro Forero Cuervo
Subject: Re: [Chicken-users] (current-seconds) returning negative values
Date: Tue, 13 Jan 2004 11:33:13 -0500
User-agent: Mutt/1.5.4i


> Urgh. Indeed. I'll change `current-seconds' to return
> a floating-point number.

Assuming that you get more than the current 29 bits (30 minus one
for negative numbers)  of precision, this will be  a good option,
as it maintains source code compatibility.

My current workaround  (that I coded to minimize  downtime in the
application I have at <>  until I get a working
version of Chicken)  is rather ugly, but I thought  I would share
it in case someone else finds it useful:

> (declare (unit time-ext))
> (define seconds-base
>   (* 24 60 60 (+ (* 365 (- 2004 1970)) 8)))
> (define (get-seconds)
>   (get-seconds-p (current-seconds)))
> (define (get-seconds-p s)
>   (+ (- (expt 2 30) seconds-base) (+ (expt 2 30) s)))

As you can see,  I redefine the epoch to mean  the year 2004 (you
could  use other  values  by defining  seconds-base to  something
else).   Needless  to  say,  I call  ``get-seconds''  instead  of
``current-seconds'' and had  to modify the timestamps  that I had
stored in my data files.

Thanks, Felix!


Ps: I've been trying to subscribe to the list without success.  I
can't find any message sent to me as a result of filling the form

The mere formulation of a problem is far more essential than its solution.
      -- Albert Einstein.

$0='!/sfldbi!yjoV0msfQ!sfiupob!utvK'x44;print map{("\e[7m \e[0m",chr ord
"219CC1CCC033E7E660198CCE4E66798303873CCE60F3387$F"#Don't you love Perl?

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]