JRS: In article <
[email protected]>, seen
in news:comp.lang.javascript said:
JRS: In article <
[email protected]>, seen
in news:comp.lang.javascript, Michael Winter <M.Winter@[no-spam]> posted
at Thu, 13 Nov 2003 02:25:51 :-
// 86400000 is the number of milliseconds in a day
That contains a false comment,
That one; but on average it is right.
Date.valueOf() returns the primitive value of the Date object: the
number of milliseconds that have elapsed since 01-Jan-1970 00:00:00
UTC.
So it says. Actually, it means GMT or UT, since Leap Seconds are
ignored; but that does not affect the matter in hand.
86400000 is the number of milliseconds in a day (ECMA-262, section
15.9.1.1)
At this stage of section 15.9, we are still using Real Time; GMT, in
effect. We have not reached a 15.9.1.9 (my copy of ECMA has 2 of
those). ECMA is correct here, although it could be expressed better.
Recall what you may have done about 19 days ago; in principle at 01:00
GMT on Sunday 26th.
When called in the EU on Mon 2003-03-31 but before 01:00 local time; at
the same local time a week later in much of North America; at the
corresponding spring date in many other places, including NZ and much of
AU; and similarly in other years.
Also, differently, for EU/US Sun 2003-10-26 after 23:00 local, etc.
Moreover, it doesn't matter what date the operation
returns.
The comment says "date one day ago", and the code does not always
comply. If the comment has said 24 hours ago, that would have been
different.
The point is to create a Date that is before the present: 24
hours earlier is a safe way of accomplishing that.
It is not.
I presented the date manipulations in that manner because I was under
the impression that setHours() should take values that are within
normal limits (0 <= hours < 24, 0 <= mins < 60, 0 <= secs < 60, 0 <=
ms < 999) These are listed in Netscape's JavaScript reference.
However, I did not see in the description that attempts will be made
to roll-over values outside of those limits.
QUOTE of NS, page Last Updated: 05/28/99 11:59:09 :
If a parameter you specify is outside of the expected range, setHours
attempts to update the date information in the Date object accordingly.
For example, if you use 100 for secondsValue, the minutes will be
incremented by 1 (min + 1), and 40 will be used for seconds.
NS guide "Last Updated September 28, 2000" is an inferior work,
probably produced by a PR department rather than a programmer.
All the set* methods have similar statements, apart from setYear
(inapplicable), setTime (ditto), setDate (seemingly an accidental
omission); likewise Date.UTC.
Note how ECMA MakeDate uses MakeDay & MakeTime; and that their
parameters must be finite, but need be no smaller.
Rollover of date-time fields has been used quite frequently in this
newsgroup for some years; perhaps you arrived since it was last
mentioned, and have not taken into account what the FAQ says about Date?
BTW, a simpler way to get an expiry Date Object set before the present
moment is new Date(0).
When referring to different expiry dates: it is not clear whether your
"last" means the one most recently given or the one latest in value.