By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,244 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,244 IT Pros & Developers. It's quick & easy.

Date Range for Date Function

P: n/a
What is the maximum valid date range for the date(yyyy,mm,dd) function.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
JRS: In article <12*************************@domain.invalid>, seen in
news:comp.lang.javascript, Dennis M. Marks <de******@domain.invalid>
posted at Mon, 12 Apr 2004 15:54:43 :
What is the maximum valid date range for the date(yyyy,mm,dd) function.


AFAICS, no such function exists. The function Date(...) appears to
exist, and may be equivalent to new Date() . I've not checked ECMA-
262; you can do that.

However, new Date(Y, M', D) exists.

It is valid from -271821-04-20 to 275760-09-12 GMT, I believe, but,
depending on interpretation, omitting years 0 to 99.

You could have discovered that by using the newsgroup FAQ.

D = new Date(0) ; D.setFullYear(Y, M', D)
D = new Date(0) ; D.setUTCFullYear(Y, M', D)
treat the First Century as it ought to be treated.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for 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.
Jul 23 '05 #2

P: n/a
In article <ae**************@merlyn.demon.co.uk>, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
JRS: In article <12*************************@domain.invalid>, seen in
news:comp.lang.javascript, Dennis M. Marks <de******@domain.invalid>
posted at Mon, 12 Apr 2004 15:54:43 :
What is the maximum valid date range for the date(yyyy,mm,dd) function.


AFAICS, no such function exists. The function Date(...) appears to
exist, and may be equivalent to new Date() . I've not checked ECMA-
262; you can do that.

However, new Date(Y, M', D) exists.

It is valid from -271821-04-20 to 275760-09-12 GMT, I believe, but,
depending on interpretation, omitting years 0 to 99.

You could have discovered that by using the newsgroup FAQ.

D = new Date(0) ; D.setFullYear(Y, M', D)
D = new Date(0) ; D.setUTCFullYear(Y, M', D)
treat the First Century as it ought to be treated.


Why can't you give direct answers? You knew I was referring to date
functions and just because I had lower case rather than upper case in
my question is no reason to act as you do. Why don't you get off your
high horse?

I went to www.faqs.org to find the FAQ and it referred to a website
that does not exist. Where are the FAQs?

Since the Gregorian calendar began 15 October 1582, I wanted to know
what dates were valid for the function. The date -271821-04-20 does not
exist in the Gregorian calendar. Does the function change to the Julian
calendar prior to that date? What happens to the days that don't exist
due to the calendar change?

What would be nice to know is the algorithm that the date function uses
to calculate day of week.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #3

P: n/a
"Dennis M. Marks" <de******@domain.invalid> writes:
I went to www.faqs.org to find the FAQ and it referred to a website
that does not exist. Where are the FAQs?
It is posted every week (twice?) in the newsgroup. Since you seem to
be a regular reader, you will probably have seen the subject several
times.
It is also available on the web at
<URL: http://jibbering.com/faq/ >
What would be nice to know is the algorithm that the date function uses
to calculate day of week.


It's described in ECMA 262 v3, section 15.9. It is available as PDF
from, e.g., <URL:http://www.mozilla.org/js/language/E262-3.pdf>
Day of Week in particular is section 15.9.1.6.
For the time value t, the week day is
WeekDay(t) = ((floor(t / 864E5)) + 4) modulo 7
where t=0 is 1st of January 1970 UTC.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4

P: n/a
In article <n0**********@hotpop.com>, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
"Dennis M. Marks" <de******@domain.invalid> writes:
I went to www.faqs.org to find the FAQ and it referred to a website
that does not exist. Where are the FAQs?


It is posted every week (twice?) in the newsgroup. Since you seem to
be a regular reader, you will probably have seen the subject several
times.
It is also available on the web at
<URL: http://jibbering.com/faq/ >
What would be nice to know is the algorithm that the date function uses
to calculate day of week.


It's described in ECMA 262 v3, section 15.9. It is available as PDF
from, e.g., <URL:http://www.mozilla.org/js/language/E262-3.pdf>
Day of Week in particular is section 15.9.1.6.
For the time value t, the week day is
WeekDay(t) = ((floor(t / 864E5)) + 4) modulo 7
where t=0 is 1st of January 1970 UTC.

/L

Thank you.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #5

P: n/a
JRS: In article <14*************************@domain.invalid>, seen in
news:comp.lang.javascript, Dennis M. Marks <de******@domain.invalid>
posted at Wed, 14 Apr 2004 16:34:47 :
In article <ae**************@merlyn.demon.co.uk>, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
JRS: In article <120420041554432353%de******@domain.invalid>, seen in
news:comp.lang.javascript, Dennis M. Marks <de******@domain.invalid>
posted at Mon, 12 Apr 2004 15:54:43 :
>What is the maximum valid date range for the date(yyyy,mm,dd) function.
AFAICS, no such function exists. The function Date(...) appears to
exist, and may be equivalent to new Date() . I've not checked ECMA-
262; you can do that.

However, new Date(Y, M', D) exists.

It is valid from -271821-04-20 to 275760-09-12 GMT, I believe, but,
depending on interpretation, omitting years 0 to 99.

You could have discovered that by using the newsgroup FAQ.

D = new Date(0) ; D.setFullYear(Y, M', D)
D = new Date(0) ; D.setUTCFullYear(Y, M', D)
treat the First Century as it ought to be treated.

I went to www.faqs.org to find the FAQ and it referred to a website
that does not exist. Where are the FAQs?
I did not write "the FAQs", but "the newsgroup FAQ". The newsgroup FAQ
is posted here on Mondays, Wednesdays, and Fridays (in two parts), and
was cited in the signature of my previous article (when I refer to the
FAQ, that is generally the case). By now, you should have noticed it -
indeed, you should have read it.

aside: Anyone know the source of the Snow quotation along the
lines of "I don't day that he should have written a
book; I do say that he should have read one." ?

Since the Gregorian calendar began 15 October 1582, I wanted to know
what dates were valid for the function. The date -271821-04-20 does not
exist in the Gregorian calendar.
Indeed it does; the proleptic Gregorian Calendar runs indefinitely
backwards from the local change date, and is used in javascript, which,
as distributed, knows nothing of the Julian calendar (see my js-date.htm
for some Julian date methods). Date methods accepting numeric years
follow (apparently reliably), the astronomical convention, in which the
Year 1 is preceded by the years 0, -1, -2, ...

Does the function change to the Julian
calendar prior to that date? What happens to the days that don't exist
due to the calendar change?
No; therefore there are no such days.

If javascript attempted to deal with calendar changes; it would be in
great difficulties as regards the Alaskan calendar for 1867 - and even
more so for the Saudi calendar.

It would also need to consider the time of the change (our American
Colonies did not make the change at the same instant as His Majesty did
here; though they did make it at the same time), and the possible
influence of the Summer Time rules.
What would be nice to know is the algorithm that the date function uses
to calculate day of week.


Given the wisdom of the average systems programmer in the relevant
country, it's hard to predict what algorithm might be used. As the date
object stores date/time as a count, the sensible method is based on
modulo-7. ECMA gives an algorithm; but it's somewhat of a /post hoc/
document, and the only requirement is that the results should agree with
that.

--
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.
Jul 23 '05 #6

P: n/a
JRS: In article <n0**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Thu, 15 Apr 2004 02:14:48 :
"Dennis M. Marks" <de******@domain.invalid> writes:
I went to www.faqs.org to find the FAQ and it referred to a website
that does not exist. Where are the FAQs?


It is posted every week (twice?) in the newsgroup. Since you seem to
be a regular reader, you will probably have seen the subject several
times.
It is also available on the web at
<URL: http://jibbering.com/faq/ >
What would be nice to know is the algorithm that the date function uses
to calculate day of week.


It's described in ECMA 262 v3, section 15.9. It is available as PDF
from, e.g., <URL:http://www.mozilla.org/js/language/E262-3.pdf>
Day of Week in particular is section 15.9.1.6.
For the time value t, the week day is
WeekDay(t) = ((floor(t / 864E5)) + 4) modulo 7
where t=0 is 1st of January 1970 UTC.

ECMA 15.9 is not well-written. Up to and including 15.9.1.6, it uses
exclusively UTC, although referring to such as Year Month Day which are
normally thought of as changing in or near the middle of the local
darkness.

15.9.1.7 is missing.

15.9.1.8 introduces local time.

15.9.1.9-the-first introduces Summer time, and
15.9.1.9-the-second describes local <-> UTC conversion.

The *actual* algorithm for getDay is in 15.9.5.16, which uses 15.9.1.9-
the-second as well as 15.9.1.6.

<URL:http://www.merlyn.demon.co.uk/js-date3.htm#KSTR> (was #STR), part
"Set a Date Object", needs thoughtfully checking by a European whose
browser uses the correct EU Summer Time rules ...

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links;
some Astro stuff via astro.htm, gravity0.htm; quotes.htm; pascal.htm; &c, &c.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #7

P: n/a
In article <14*************************@domain.invalid>, Dennis M. Marks
<de******@domain.invalid> writes

<snip>
Since the Gregorian calendar began 15 October 1582, I wanted to know
what dates were valid for the function. The date -271821-04-20 does not
exist in the Gregorian calendar. Does the function change to the Julian
calendar prior to that date? What happens to the days that don't exist
due to the calendar change?
No. I'm afraid you need to think clearly about calendars and dates and
days. A calendar gives names (or numbers) to days. There are many
calendars. Which one it's best to use depends on circumstances and on
who you're talking to.

For instance, the Russian revolution started in October 1914 when Russia
was using the Julian calendar, and its anniversaries were celebrated in
November because Russia later adopted the Gregorian calendar. It's still
called the October revolution.

Use of the Gregorian calendar may have started in 1582, but that
calendar names days as far into the past and as far into the future as
it's sensible to talk about "days". (I.e. Billions of years).

Another complication if you want to be historically accurate is that
until fairly recently the year number changed on March 25 (Julian), not
on Jan 1. That's why the English tax year starts on April 6 (Gregorian).
What would be nice to know is the algorithm that the date function uses
to calculate day of week.


Many modern browsers do what ECMA 262 says. Older ones might be
different.

John
--
John Harris
Jul 23 '05 #8

P: n/a
JRS: In article <rQ**************@jgharris.demon.co.uk>, seen in
news:comp.lang.javascript, John G Harris <jo**@nospam.demon.co.uk>
posted at Thu, 15 Apr 2004 21:08:49 :
For instance, the Russian revolution started in October 1914 when Russia
was using the Julian calendar, and its anniversaries were celebrated in
November because Russia later adopted the Gregorian calendar. It's still
called the October revolution.
While they were usually revolting, this particular October was in 1917.
The Octobrists, however, refers to 1905.

Another complication if you want to be historically accurate is that
until fairly recently the year number changed on March 25 (Julian), not
on Jan 1. That's why the English tax year starts on April 6 (Gregorian).


In part.

When England used the Julian Calendar, taxpayers were naturally granted,
*every* fourth year, an extra day between tax-due dates.

In the 1750s, March 25 Julian was April 5 Gregorian (difference 11
days), so the start of the tax year did not change, but was re-labelled
April 5th.

When a Leap Day was omitted in 1800 under the Gregorian Rules, the then-
considerate (or cowardly) authorities granted the customary extra day by
shifting the date to April 6th; alas, in 1900 this due boon was not
granted. Or so I believe.

--
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.
Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.