In comp.lang.javascript message <lghpc5dq02b5vs17m33dn6vlo85vjpq8rt@4ax.
com>, Wed, 7 Oct 2009 18:49:45, Hans-Georg Michna <hans-
> posted:
>On Tue, 6 Oct 2009 20:12:45 +0100, Dr J R Stockton wrote:
>
>>The term is good enough for ISO/IEC 16262 15.9, which (for example)
>>includes "A Date object contains a number indicating a particular
>>instant in time to within a millisecond. The number may also
>>be NaN, indicating that the Date object does not represent a specific
>>instant of time.".
>
>While you're at it, I've seen scripts that compare two Date
>objects directly, but I could not find any clue in any
>specification that this should work.
To most people, I guess it's not obvious what D1 == D2 does; I believe
it compares the objects to see if they are the same object. One might
think it could compare the toString() results, but that would be
wasteful of effort. Just compare +D1 with +D2.
You could have read <URL:http://www.merlyn.demon.co.uk/js=-date0.htm#DC>
instead of asking.
>The quoted text above also mentions the contained milliseconds,
>but it does not say that the Date object behaves like a number.
I only quoted the part of the document relevant to previous discussion;
if you want to know more, you should read it.
>It does not say how you get at those milliseconds. Elsewhere it
>is specified that you can use .getTime() to get at them.
Or .valueOf() - and if you consider the whole document you will see that
a unary + operator should do it (it does, and unary - does, and D-0
works, as does multiplying or dividing by 1, or using Number(D) ).
AFAICS, a Date object is not required to store its value as an IEEE
Double; but it is required to behave as if that were the case (apart
from the speed of operations, which is unspecified). There might be
advantage in actually storing a 64-bit signed integer.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.