Please try the following commands in your JS console: a = new Date() a.getTime() // shows 1369376858656 (new Date(a)).getTime() // shows 1369376858000 This sounds no good. I don't know who is proper to take this one.
http://www.ecma-international.org/ecma-262/5.1/#sec-184.108.40.206 > 1. Let v be ToPrimitive(value). http://www.ecma-international.org/ecma-262/5.1/#sec-9.1 > Object Return a default value for the Object. The default value of an > object is retrieved by calling the [[DefaultValue]] internal method of the > object, passing the optional hint PreferredType. http://www.ecma-international.org/ecma-262/5.1/#sec-8.12.8 > When the [[DefaultValue]] internal method of O is called with no hint, then it > behaves as if the hint were Number, unless O is a Date object (see 15.9.6), in > which case it behaves as if the hint were String. > When the [[DefaultValue]] internal method of O is called with hint String, the following steps are taken: (Loughly speaking, it will end up with calling O.toString()) http://www.ecma-international.org/ecma-262/5.1/#sec-220.127.116.11 > This function returns a String value. The contents of the String are > implementation-dependent, but are intended to represent the Date in the > current time zone in a convenient, human-readable form. > NOTE For any Date value d whose milliseconds amount is zero, the result of > Date.parse(d.toString()) is equal to d.valueOf(). See 18.104.22.168. To wrap up, this is because Firefox don't contain milliseconds in the Date.prototype.toString() result which is allowed by the spec. If I executes |a.toString = a.toISOString|, |(new Date(a)).getTime()| returned the same value as |a.getTime()|. You shouldn't rely on implementation-dependent behaviors.
Assignee: nobody → general
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Product: Firefox → Core
Resolution: --- → INVALID
OK, I see. Thanks for the info! :)
You need to log in before you can comment on or make changes to this bug.