Dr
Fri Aug 18 06:49:26 CDT 2006
JRS: In article <uniq2FjwGHA.4280@TK2MSFTNGP04.phx.gbl>, dated Thu, 17
Aug 2006 15:15:10 remote, seen in news:microsoft.public.scripting.vbscri
pt, Walter Zackery <please_respond_to@group.com> posted :
>
>The fundamental problem is that the length of a year, month and week can all
>vary.
Your code uses a fixed length for the week. That's fine for those
following ISO 8601 or religious tradition; but in places such as the USA
the customary numberings of weeks imply variable length...
> So depending on your starting point 60 days can be 2 months and 1 day,
>2 months, 1 month and 30 days or 1 month and 29 days.
Of course.
> The question is, do
>you want the same interval of elapsed time to always return the same result?
Unfortunately, the ordinary people, including management, will want that
and will also want the interval between a date and the same date in the
next month or year to be an exact number of months or years. They
cannot have both.
>Or should it depend on the years and months that you're starting with. I
>chose the former approach. You probably chose the latter approach. I don't
>see either method as being inherently superior; it depends on what you're
>trying to achieve.
Those who ask for such code must be made to realise that they have at
least four choices; to do it in your fashion, to count forwards in whole
years, months, ... from the beginning (or maybe backwards if it's a
time-to-wait), to use Thirty-Day Months, or not to call for such a
display after all.
Your code has the result that, if the months part is 0..11 respectively,
the upper limit on the days part is something like 30, 27/8, 30, 29,
..., 30 respectively, which is rather peculiar.
The essential for the employed coder is to get a solid specification
agreed with management.
Should those who foresee being required to serve a six-month sentence in
prison endeavour to have the interval include Feb 28 followed by Mar 1 ?
For some purposes, nominal 30-day months should be used :
<URL:
http://www.merlyn.demon.co.uk/js-date3.htm#30DM>
<URL:
http://www.merlyn.demon.co.uk/moredate.htm#30DM>
and there the US does not follow the same rule as the EU, but a more
complex one.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:
http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:
http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:
http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.