473,498 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date in Opera 9.50


In Opera 9.2x, new Date.getYear() gives 108.
In Opera 9.50, new Date.getYear() gives 2008.
AIUI, IIRC, etc., ECMA & ISO/IEC require Year-1900.
9.2x was right, 9.50 agrees with IE 6 & 7.

Do we agree? Anything else interesting noticed?

--
(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 moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jun 27 '08 #1
5 1028
Dr J R Stockton <jr*@merlyn.demon.co.ukwrites:
In Opera 9.2x, new Date.getYear() gives 108.
In Opera 9.50, new Date.getYear() gives 2008.
AIUI, IIRC, etc., ECMA & ISO/IEC require Year-1900.
9.2x was right, 9.50 agrees with IE 6 & 7.

Do we agree?
The getYear method is not part of ECMAScript proper, but is specified
in the non-normative Annex B (B.2.4 to be exact). I.e., it's a
*suggested* implementation for compatability reasons, but not
required.
In practice, agreeing with IE is probably a better compatability
choice.
Anything else interesting noticed?
Nothing so far. The typical bugs in Array.prototype.sort, but everybody
has those :)

/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.'
Jun 27 '08 #2
On Jun 17, 1:13 pm, Lasse Reichstein Nielsen <l...@hotpop.comwrote:
Dr J R Stockton <j...@merlyn.demon.co.ukwrites:
[snip]
>
Anything else interesting noticed?

Nothing so far. The typical bugs in Array.prototype.sort, but everybody
has those :)
Can you elaborate on that?

Garrett
/L
Jun 27 '08 #3
dhtml <dh**********@gmail.comwrites:
On Jun 17, 1:13 pm, Lasse Reichstein Nielsen <l...@hotpop.comwrote:
>Nothing so far. The typical bugs in Array.prototype.sort, but everybody
has those :)

Can you elaborate on that?
Array.prototype.sort's default comparison is required to sort the
array elements so that the "undefined" value is greater than all
other values, but less than no value at all. I.e., if the array
doesn't have a value at an index at all (as opposted to having
a value that is undefined), then the sorted array will too, and
it will have those at the end.

Or, to quote 15.4.4.11:

There must be some mathematical permutation p of the nonnegative
integers less than Result(2), such that for every nonnegative integer
j less than Result(2), if property old[j] existed, then new[p(j)] is
exactly the same value as old[j],. but if property old[j] did not
exist, then new[p(j)] does not exist.

Then for all nonnegative integers j and k, each less than Result(2),
if SortCompare(j,k)<0 (see SortCompare below), then p(j)< p(k).

and SortCompare(j,k) (where j and k are indices) is defined as:

1. Call ToString(j).
2. Call ToString(k).
3. If this object does not have a property named by Result(1), and this object does not have a
property named by Result(2), return +0.
4. If this object does not have a property named by Result(1), return 1.
5. If this object does not have a property named by Result(2), return -1.
6. Call the [[Get]] method of this object with argument Result(1).
7. Call the [[Get]] method of this object with argument Result(2).
8. Let x be Result(6).
9. Let y be Result(7).
10. If x and y are both undefined,return +0.
11. If x is undefined,return 1.
12. If y is undefined,return -1.
13. If the argument comparefn is undefined, goto step 16.
14. Call comparefn with arguments x and y.
15. Return Result(14).
16. Call ToString(x).
17. Call ToString(y).
18. If Result(16) < Result(17), return -1.
19. If Result(16) Result(17), return 1.
20. Return +0.

I.e., step 3..5 means that missing properties are sorted last,
step 6..12 means that undefined are sorted just before those,
and for all other values, their string representation is compared.

Example: The array:
var a = [42,NaN,0,"",,false,undefined,null,,true]
has a length of 10, but only 9 elements. The expressions
(4 in a)
and
(8 in a)
both evaluate to false.
Sorting it using
a.sort()
should give the equivalent of
["",0,42,NaN,false,null,true,undefined,,,]

Try the following in different browsers:
var a = [42,NaN,0,"",,false,undefined,null,,true]
a.sort();
function prettyArray(arr) {
var res = [];
res.length = arr.length;
for(var i = 0; i < arr.length; i++) {
if (i in arr) {
var pretty;
if (typeof arr[i] == "string") {
res[i] = '"' + arr[i] + '"';
} else {
res[i] = String(arr[i]);
}
}
}
if (!((arr.length-1) in arr)) { res.length++; }
return "[" + res.join(",") + "]";
}
alert(prettyArray(a));
In Opera, one of the missing elements is converted to an existing
element with value "undefined":
alert(8 in a); // Opera: true!
In Firefox 3, both missing elements are converted to undefined values:
alert(8 in a); // FF3: true!
alert(9 in a); // FF3: true!
IE 7 actually removes the undefined value:
alert(7 in a); // IE7: false!
(It doesn't help that IE fails to ignore a final comma in array literals:
[42,].length == 2 // IE7. Should be 1
)

Safari actually appears to sort it correctly.
/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.'
Jun 27 '08 #4
In comp.lang.javascript message <7i**********@hotpop.com>, Tue, 17 Jun
2008 22:13:57, Lasse Reichstein Nielsen <lr*@hotpop.composted:
^^^^^^^^^^^^^^

A non-working address there is forgivable, except by the obnoxious; but
it should not be repeated in the signature.
>Dr J R Stockton <jr*@merlyn.demon.co.ukwrites:
>Anything else interesting noticed?
Call new Date(Y, M, D) still is limited to four-digit years.

In new Date("1970/01/01 EST") EST is still ignored.

Ctrl-Alt-V no longer validates via w3, alas, at least by default.
Firefox 3 has fixed the Date.UTC(Y,M,D) D<=0 error; it was treated
before as D=1. And its time resolution of new Date() seems to be
better, 1 ms rather than 15.625 - that needs checking..

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jun 27 '08 #5
On Jun 18, 1:04*am, Lasse Reichstein Nielsen <l...@hotpop.comwrote:
dhtml <dhtmlkitc...@gmail.comwrites:
On Jun 17, 1:13 pm, Lasse Reichstein Nielsen <l...@hotpop.comwrote:
Nothing so far. The typical bugs in Array.prototype.sort, but everybody
has those :)
Can you elaborate on that?

Array.prototype.sort's default comparison is required to sort the
array elements so that the "undefined" value is greater than all
other values, but less than no value at all. I.e., if the array
doesn't have a value at an index at all (as opposted to having
a value that is undefined), then the sorted array will too, and
it will have those at the end.
[snip]

[snip]
In Opera, one of the missing elements is converted to an existing
element with value "undefined":
* alert(8 in a); // Opera: true!
In Firefox 3, both missing elements are converted to undefined values:
* alert(8 in a); // FF3: true!
* alert(9 in a); // FF3: true!
IE 7 actually removes the undefined value:
* alert(7 in a); // IE7: false!
(It doesn't help that IE fails to ignore a final comma in array literals:
* [42,].length == 2 // IE7. Should be 1
)
Multi-line copy-paste, select example, and GO:
javascript:void(eval("(function(){"
+ (document.selection&& document.selection.createRange &&
document.selection.createRange().text || window.getSelection())
+"})()"));

Pretty bad for sort to be adding/removing properties.

It's not just sort(), though.

javascript:alert('0'in [,].concat()); // true in Opera, FF2
javascript:alert('0'in [,]); // true in FF2, false in Opera.

I thought the When encountering a trailing comma, IE interprets that
as an Elision. IOW, when IE sees - ElementList, - IE instead
interprets it as the source text - ElementList,Elision - or -
ElementList,, - should be interpreted.

javascript:alert("1"in[,]); // false in IE.

But:
javascript:alert([,].length); // 2 in IE.

Should be 1.

Although the ES3 deviations doc is not quite right:-

"2.6 Array Initialiser: §11.1.4
Trailing commas in array literals add to the length, but they
shouldn't. JScript treats the empty element after the trailing comma
as undefined."
http://wiki.ecmascript.org/lib/exe/f...onsfromes3.pdf

That's not actually what JScript does. JScript treats it as an
Elision.

Garrett
Safari actually appears to sort it correctly.
Safari's not doing too bad.
/L
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
19783
by: Jo | last post by:
Is there anyway we can know using JavaScript the Short Date Format used in the Control Panel -> Regional and Language Settings? I know the using the combinations of following we can get the...
13
2205
by: Dr John Stockton | last post by:
Javascript date strings can have a one-letter postfix; it is taken as indicating time zone (not J, which causes NaN). // IIRC, VB accepts A & P in that location, for AM & PM. In my MS IE 4, the...
9
1749
by: Mike Hyndman | last post by:
I have a small script on a website that that changes the greeting according to the time of day and displays the current day and date. This works fine in Internet Explorer, but when viewed in Opera,...
1
1564
by: FatBoyThin | last post by:
I love it when I back myself into a corner. Seems to be the fastest way to learn. I have 3 tables; tblINBOX, tblOUTBOX and tblPENDING The relevant rows are as following; Date, userID userID is...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.