chicken-users
[Top][All Lists]

## [Chicken-users] RE: srfi-19 time, flonums and s11n

 From: Shawn Rutledge Subject: [Chicken-users] RE: srfi-19 time, flonums and s11n Date: Wed, 5 Sep 2007 10:54:23 -0700

```On 9/5/07, Kon Lovett <address@hidden> wrote:
>
> On Sep 3, 2007, at 11:36 AM, Shawn Rutledge wrote:
<snip>
> > But is there any way that it could
> > be legal to change the definition of the epoch?
> >
> > Specification
> >
> > A Time object, which is distinct from all existing types, defines a
> > point in time or a time duration in some standard time system. The
> > standard time systems are:
> >
> >     * Universal Coordinated Time (UTC),
> >     * International Atomic Time (TAI),
> >     * monotonic time (a monotonically increasing point in time from
> > some epoch, which is implementation-dependent), ...
>
> Go ahead, but must have a mode where time-monotonic = time-tai.

That is required by the SRFI or some other spec, or just a convention
of this implementation?  If it is necessary to maintain this
equivalence, then maybe there should be a different type of time for
the alternate epoch; the SRFI says you can add different types beyond
the required ones.

Anyway I'm beginning to think that for my purpose flonums aren't so
bad after all; because two 32-bit ints take up the same space as one
double, but with doubles you can do math directly (faster on some
platforms than others) rather than having to write more logic to
handle the seconds and nanoseconds separately.  So I will just store
the timestamp of an event as a plain flonum and worry later about what
forms it can be converted into.  (And it's not necessary to load any
SRFI code that way.)  For purposes of checking event order, a
comparison on a double would seem to be more efficient than either of
the SRFI time representations (SRFI-18 or 19).  From an OO perspective
it's better to know what that number is rather than making an implicit
assumption, but whatever... I don't really like the complexity of both
implementations.

http://en.wikipedia.org/wiki/Unix_time says Posix defines the
timestamp as seconds since 1970 without taking leap seconds into
account.  So Posix time is identical to monotonic time as defined in
SRFI-19, right?

```