473,796 Members | 2,703 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.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.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 1043
Dr J R Stockton <jr*@merlyn.dem on.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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #2
On Jun 17, 1:13 pm, Lasse Reichstein Nielsen <l...@hotpop.co mwrote:
Dr J R Stockton <j...@merlyn.de mon.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**********@g mail.comwrites:
On Jun 17, 1:13 pm, Lasse Reichstein Nielsen <l...@hotpop.co mwrote:
>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,retur n +0.
11. If x is undefined,retur n 1.
12. If y is undefined,retur n -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,"",,fa lse,undefined,n ull,,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,fal se,null,true,un defined,,,]

Try the following in different browsers:
var a = [42,NaN,0,"",,fa lse,undefined,n ull,,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(prettyArr ay(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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #4
In comp.lang.javas cript message <7i**********@h otpop.com>, Tue, 17 Jun
2008 22:13:57, Lasse Reichstein Nielsen <lr*@hotpop.com posted:
^^^^^^^^^^^^^^

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.dem on.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.demo n.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.co mwrote:
dhtml <dhtmlkitc...@g mail.comwrites:
On Jun 17, 1:13 pm, Lasse Reichstein Nielsen <l...@hotpop.co mwrote:
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("(functio n(){"
+ (document.selec tion&& document.select ion.createRange &&
document.select ion.createRange ().text || window.getSelec tion())
+"})()"));

Pretty bad for sort to be adding/removing properties.

It's not just sort(), though.

javascript:aler t('0'in [,].concat()); // true in Opera, FF2
javascript:aler t('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,Eli sion - or -
ElementList,, - should be interpreted.

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

But:
javascript:aler t([,].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
19813
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 Locale Long Name format toString() toLocaleString() toLocaleDateString()
13
2236
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 object generated by new Date("2001/1/1 0:0:0R") has value meaning Sun Dec 31 19:00:00 UTC 2000. That combination of local time and UTC corresponds, AIUI, to Tashkent and Karachi, in Asia (and not to any US towns of the...
9
1764
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, 2005 displays as 105. Any help with this gratefully recieved. TIA MH remove -bats- to reply
1
1599
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 a 5 digit number I understand how to construct a query to return a count of the userID for a date range for a single table. I'm stumped on how to get a single query that will give me the count of the userID for a date range.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10018
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5446
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
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 we have to send another system

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.