[webkit-dev] currentTime() and UTC time

Darin Adler darin at apple.com
Mon Apr 19 17:43:56 PDT 2010

On Apr 16, 2010, at 8:50 AM, Yong Li wrote:

> The default implementation of JS Date is calling currentTime() (by jsCurrentTime()), so it assumes currentTime() returns current UTC time, and system UTC time can be changed. However, currentTime() is also used in most cases as a system tick count, which means it should always be monotonically increasing. I guess we should remove the dependency on currentTime() from JS Date to fix the confliction.

It seems OK to replace the current time function with two functions, one which returns a monotonically increasing time that may have no relationship with the UTC date and time and another that returns the UTC date and time. You have pointed out that currently all clients want either one or the other.

A good way to do this would be to make separate names for the two functions, have them both be the same for the moment, and change all call sites.

The function used for this on Mac OS X, CFAbsoluteTimeGetCurrent, is a thin wrapper on top of the gettimeofday function. I suppose we could move to use the clock function instead for monotonically increasing version.

    -- Darin

More information about the webkit-dev mailing list