From: Dr J R Stockton on
In comp.lang.javascript message <9d6vc5ltiomn415vksacd9ivk13999epfh(a)4ax.
com>, Fri, 9 Oct 2009 22:43:17, Hans-Georg Michna <hans-
georgNoEmailPlease(a)michna.com> posted:
>On Fri, 9 Oct 2009 04:06:00 -0700 (PDT), Richard Cornford wrote:

>> ...
>>implementation (and you still need ECMA 262 in order to know what is
>>or is not an extension), or an ECMAScript implementation bug.
>> ...

>Yes, I see your point. I take it that that is the normative
>documentation.

Only in practice.

It is outranked by ISO/IEC 16262, which is a later version of
substantially the same document (and IMHO more readable). No technical
change was intended between the documents.

One major browser maker, however, has evident difficulty in correctly
implementing at least one International Standard. Coders should not
rely on equal compliance in all browsers.

--
(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.
From: Garrett Smith on
Garrett Smith wrote:
> Dr J R Stockton wrote:
>> In comp.lang.javascript message <haj2vd$j23$1(a)news.eternal-
>> september.org>, Wed, 7 Oct 2009 14:59:03, Garrett Smith
>> <dhtmlkitchen(a)gmail.com> posted:
>>> John G Harris wrote:
>>>> On Mon, 5 Oct 2009 at 19:43:47, in comp.lang.javascript, Dr J R
>>>> Stockton
>>>> wrote:
>>>>> In comp.lang.javascript message
>>>>> <4ac928fb$0$289$14726298(a)news.sunsite.dk
>>>>>> , Sun, 4 Oct 2009 23:00:03, FAQ server <javascript(a)dotinternet.be>
>>>>> posted:
>>>>>
>
> [...]
>>>> Strictly speaking, the Date Object is the object named Date : the
>>>> constructor you use when you do new Date().
>>>>
>>> And one of those is "a Date".
>>>
>>> A Date *is* and Object. Adding "Object" is redundant.
>>
> correction: A Date *is* an Object.
>
>> It is not superfluous, since "date" is an ordinary English word and may
>> also be used with that meaning - and in a natural language a little
>> redundancy is often a great help in transferring a meaning without
>> either error or doubt.
>>
> In context of a javascript FAQ, capitalized "Date" seems obvious to me.
> Are there others who feel it is confusing?


How does this look?

function formatDate(dateInRange) {
var year = dateInRange.getFullYear(),
isInRange = year >= 0 && year <= 9999,
yyyy, mm, dd;
if(!isInRange) {
throw RangeError("formatDate: year must be 0000-9999");
}
yyyy = ("000" + year).slice(-4);
mm = ("0" + (dateInRange.getMonth() + 1)).slice(-2);
dd = ("0" + (dateInRange.getDate())).slice(-2);
return yyyy + "-" + mm + "-" + dd;
}
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Johannes Baagoe on
Garrett Smith :

> How does this look?
>
> function formatDate(dateInRange) {
> var year = dateInRange.getFullYear(),
> isInRange = year >= 0 && year <= 9999, yyyy, mm, dd;
> if(!isInRange) {
> throw RangeError("formatDate: year must be 0000-9999");
> }
> yyyy = ("000" + year).slice(-4);
> mm = ("0" + (dateInRange.getMonth() + 1)).slice(-2);
> dd = ("0" + (dateInRange.getDate())).slice(-2);
> return yyyy + "-" + mm + "-" + dd;
> }

Excellent, as far as I can see, with just one possible problem : year
zero, which is admissible in some contexts but not, e.g., in XQuery.

Unless there are reasons to believe users will actually know what it means
and require its use, I suggest replacing "year >= 0" with "year > 0".

--
Johannes
From: Hans-Georg Michna on
On Sat, 17 Oct 2009 07:19:20 -0500, Johannes Baagoe wrote:

>Excellent, as far as I can see, with just one possible problem : year
>zero, which is admissible in some contexts but not, e.g., in XQuery.
>
>Unless there are reasons to believe users will actually know what it means
>and require its use, I suggest replacing "year >= 0" with "year > 0".

Very true, but year zero should be admissible in no context,
because it never existed. There is no year zero.

I guess at the time our calendar was invented, most people
didn't have a good idea about the mystical number zero. (:-)

Hans-Georg
From: Garrett Smith on
Johannes Baagoe wrote:
> Garrett Smith :
>
>> How does this look?
>>
>> function formatDate(dateInRange) {
>> var year = dateInRange.getFullYear(),
>> isInRange = year >= 0 && year <= 9999, yyyy, mm, dd;
>> if(!isInRange) {
>> throw RangeError("formatDate: year must be 0000-9999");
>> }
>> yyyy = ("000" + year).slice(-4);
>> mm = ("0" + (dateInRange.getMonth() + 1)).slice(-2);
>> dd = ("0" + (dateInRange.getDate())).slice(-2);
>> return yyyy + "-" + mm + "-" + dd;
>> }
>
> Excellent, as far as I can see, with just one possible problem : year
> zero, which is admissible in some contexts but not, e.g., in XQuery.
>
> Unless there are reasons to believe users will actually know what it means
> and require its use, I suggest replacing "year >= 0" with "year > 0".
>

Who is the user? The person copy-pasting "formatDate" or the end user
who is interacting with the browser?

Regardless, the year 0 issue has been discussed here previously.

ISO 8601 explicitly lists year 0000.

| Calendar years are numbered in ascending order according to the
| Gregorian calendar by values in the range [0000] to [9999].

ISO 8601 is linke from that FAQ Entry:
http://jibbering.com/faq/#formatDate
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Prev: Computer Techs Wanted
Next: move div by drag etc.