I understand that.  I would also like to lobby for changes to Date.  Maybe I should just write my own library that expects the date to be a floating point number of days (like Delphi and others).  As it stands, this illustrates the big problem with the date class:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Script>
    <![CDATA[
      private var _testvar:Date = new Date(2006,1);
     
      public function set testvar(value:Date):void {
        _testvar = value;
        trace('set');   
      }

      [Bindable]
      public function get testvar():Date {
        trace('get');   
        return _testvar;
      }
    ]]>
  </mx:Script>

  <mx:Label id="lbl" x="22" y="10" text="{testvar}"/>
  <mx:Button x="22" y="56" label="&lt;&lt;" click="testvar.date--"/>
  <mx:Button x="20" y="86" label=">>" click="testvar.date++"/>
</mx:Application>

  <mx:Button x="22" y="156" label="&lt;&lt;" click="testvar.date--; testvar = new Date(testvar)"/>
  <mx:Button x="20" y="186" label=">>" click=" testvar.date++; testvar = new Date(testvar)"/>


The first two buttons don't work as expected.  That is, if you expect to fully take advantage of Flex's great databinding technology.  Instead, everywhere you simply want to increment/decrement/change the date, you have to jump through hoops to create a new date or write invalidation calls whenever you change it.  Or you do silly things like the second two buttons.  This is unavoidable for my complex objects, but dates should be as simple to use as ints and strings.

Frankly, I feel like I'm going back in time when I work with Date.  Flex has spoiled me :D


On 6/23/06, Gordon Smith < [EMAIL PROTECTED]> wrote:

> I swear, I really think the date class was designed by a crazy man.  You hear that Adobe? - CRAZY!

 

I heard it. But we didn't design the Date class; it's part of the existing _javascript_/Ecmascript standards that we've followed in ActionScirpt 3.

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto: flexcoders@yahoogroups.com] On Behalf Of Pan Troglodytes
Sent: Friday, June 23, 2006 8:02 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Difference between two dates

 

I swear, I really think the date class was designed by a crazy man.  You hear that Adobe? - CRAZY! :D

On 6/23/06, Daniel Tuppeny < [EMAIL PROTECTED]> wrote:

I was using .day instead of .date

 

TFI Friday! =)

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Daniel Tuppeny
Sent: 23 June 2006 15:33
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Difference between two dates

I think I need more coffee....

 

The following code (which I'm sure is correct!), returns around 2.8 when I'm expecting around 3.2. Anyone spot my error?

 

 

 

public static function getMonths(startDate:Date, endDate:Date):Number
  {
   if (startDate > endDate)
   {
    var tmp:Date = endDate;
    endDate = startDate;
    startDate = tmp;
   }
   
   var numMonths:Number = 0;
   
   // Get number of months in years
   numMonths += (endDate.fullYear - startDate.fullYear) * 12
   numMonths += endDate.month - startDate.month;
   numMonths += (endDate.day - startDate.day) / 30; // This needs fixing
   
   return numMonths;
  }


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

[Inbound Mail Scanned by MessageLabs]



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________




--
Jason




--
Jason __._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to