DanielSant0s / AthenaEnv

A complete Javascript environment for creating homebrew applications and games on PlayStation 2.
GNU General Public License v3.0
156 stars 20 forks source link

Date.now() wrongly returns the current time in seconds * 1000 #3

Closed jcnmsg closed 2 years ago

jcnmsg commented 2 years ago

I would expect Date.now() to return the current time in milliseconds but it is effectively calculating the value in seconds and then multiplying it by 1000, which means we're actually losing the millisecond precision. The same is happening with performance.now().

I originally thought the problem was on Duktape falling back to duk_bi_date_get_now_time which only returns time in seconds (and multiplies it by 1000) but using duk_bi_date_get_now_gettimeofday produces the same result because gettimeofday apparently returns 0 on tv_usec.