Good to know. Thanks Francis. Scott
-----Original Message----- From: [EMAIL PROTECTED] on behalf of Francis Cheng Sent: Thu 3/23/2006 7:27 PM To: Flashcoders mailing list Cc: Subject: RE: [Flashcoders] Simple date comparison bug? This is due to the ECMAScript algorithm for determining equality. You'll find that JavaScript behaves the same way. Date objects are not primitives, so they will only compare as equal if both Date variables reference the same Date object (i.e. var d2 = d1;) The ECMAScript algorithms for <= and >=, however, convert both operands to Number before the comparison. Date objects converted to the Number data type gives you the number of milliseconds since the epoch. The upshot is that to test for equality of Date objects, either convert them to numbers first or use valueOf(): trace (Number(d1) == Number(d2)); trace (d1.valueOf() == d2.valueOf()); Francis > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:flashcoders- > [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > Sent: Thursday, March 23, 2006 3:40 PM > To: 'Flashcoders mailing list' > Subject: [Flashcoders] Simple date comparison bug? > > Don't know why I haven't come across this before, but can anyone confirm > this for me (and maybe give an explanation)? > > <code> > var d1:Date = new Date( 1970, 0 ); > var d2:Date = new Date( 1970, 0 ); > trace( d1 == d2 ); // false > trace( d1 <= d2 ); // true > trace( d1 >= d2 ); // TRUE?! > </code> > > Umm… If something is both >= *and* <= the only possibly is that it is > equal. So… WTF? > > > dave myron > principal, technical director > > contentfree > ? 206.855.5580 phone | 206.774.2767 fax > ? [EMAIL PROTECTED] > ? 337 1st ave ne. suite 100, issaquah, wa 98027 > > > _______________________________________________ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com
_______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

