Date.prototype.getTime

Peter Hall peterjoel at gmail.com
Tue Jun 27 20:07:51 PDT 2006


> I was under the impression that the following was more idiomatic, but I could be wrong:
>
> > var before = Date.now();
> > doStuff();
> > var after = Date.now();
> > var elapsedTime = after - before;
>

Perhaps. But getTime() is what is implemented in es3, and I don't
think this can change. The question is over the consistency of the
precision of this value between implementations.

I don't have a mac here to test, but I was under the impression that
timing within Actionscript had a lower precision on macs than windows
(as opposed to P.T.Withington's observation of the reverse).

I don't think it is acceptable to standardise on anything coarser than
1 millisecond precision, and it is probably not practical (or indeed
useful) to standardise on anything finer. getTime() should return an
int, representing milliseconds, not a float. I don't know what you do
about platforms where that precision is not possible to implement; and
perhaps this is why es3 does not specify a precision. (It specifies
only the fact that the unit is milliseconds, not the degree to which
that measurement is accurate).

Peter



More information about the Es4-discuss mailing list