plaa / TimeShift-js

Library for mocking JavaScript's Date object
MIT License
65 stars 28 forks source link

toLocaleDateString doesn't work in V8 when we override Date #1

Open pwmarcz opened 11 years ago

pwmarcz commented 11 years ago
> Date = TimeShift.Date
> new TimeShift.Date().toLocaleDateString()
TypeError: Method invoked on an object that is not Date.
> new TimeShift.OriginalDate().toLocaleDateString()
TypeError: Method invoked on an object that is not Date.

It looks like V8 code checks if date instanceof Date (see overrides.js) which fails when Date has been changed.

plaa commented 11 years ago

That's strange - the code always invokes the original toLocaleDateString method on the original Date object. When I run those commands in Chromium version 28, they work (though may produce the wrong string, as stated in the known issues). What are you running those commands on?