JRS: In article <FEkne.361$3d3.1814@news2.mts.net>, dated Wed, 1 Jun
2005 15:39:17, seen in news:comp.lang.javascript, Grant Wagner
<gwagner@agricoreunited.com> posted :[color=blue]
>
>
>Anyway, if you just want it as an integer where a day in the same month
>is 0 months and any day in any other month is the number of months
>different, then it's (something like):[/color]
[color=blue]
> (anotherDay.getFullYear() - today.getFullYear()) * 12 +
> (anotherDay.getMonth() - today.getMonth())[/color]
One can also calculate an "Absolute Month Number" like
function AWM(Y, M) { return Y*12+M }
and then subtract. It's numerically equivalent, and less efficient; but
the concept can be helpful in more complicated cases.
[color=blue]
>But you've still got some problems... the date the user enters may not
>be in a format that new Date() understands, so you'll need to parse it
>and ensure that it is.[/color]
Necessary but not sufficient. It is also necessary that new Date(), for
all users, interprets it in the same way as the user expects. And that
must be tested for the Nth of month M, where N != M and N < 13.
In article <gLlne.499$g5.466@twister.nyroc.rr.com>, dated Wed, 1 Jun
2005 16:54:36, seen in news:comp.lang.javascript, Mick White <mwhite13BO
GUS@rochester.rr.com> posted :[color=blue]
>
>Consider that a month is an imprecise measurement, here in NY there are
>at least 6 different month "lengths". And this disregards year end
>tweakings of the "atomic" clock.[/color]
And Lunar, Hebrew, Islamic, etc., months.
Year middle tweakings are equally favoured, and have been approximately
equally common. Tweakings at the end of odd quarters are also allowed,
but less favoured, and have not so far been needed.
There will be none at the end of this month; but the length of time
since the previous leap second now is and until the next one will remain
longer than it has ever been before (IIRC).
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
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 moredate.htm js-dates.htm pas-time.htm critdate.htm etc.