Your code leads to the same invalid value.

 

When you don't pass any arguments to the Date constructor, you get a
Date representing "right now", so 'date' is 29 because today is the
29th. When you then set the fullYear to 1987 and then month to 1
(February), you get the invalid date Feburary 29, 1987 which is
intepreted as March 1, 1987. You then set the 'date' to 3 and get March
3, 1987.

 

In more detail, here is how I think the Player is executing your code on
July 29, 2008 (today):

 

var d:Date = new Date;

   // d represents July 29, 2008

   // d.fullYear is 2008

   // d.month is 6 (July)

   // d.date is 29



d.fullYear = 1987;

   // d represents July 29, 1987

   // d.fullYear is 1987

   // d.month is 6 (July)

   // d.date is 29
   
d.month = 1; // (February)
   // d represents February 29, 1987 -- OOPS!  This is invalid but
"equivalent" to March 1, 1987, so now

   // d.fullYear is 1987

   // d.month is 2 (March)

   // d.date is 1



d.date = 3;
   // d represents March 3, 1987

   // d.fullYear is 1987

   // d.month is 2 (March)

   // d.date is 3



Please go ahead and file a bug against Flex and we'll transfer it into
the Player team's bugbase for them to determine whether this behavior is
consistent with the Ecmascript spec or not. Be sure to indicate that you
are executing this code on July 29, 2008 because the fact that today is
the 29th is crucial.

 

Gordon Smith

Adobe Flex SDK Team

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of aceoohay
Sent: Tuesday, July 29, 2008 3:09 PM
To: [email protected]
Subject: [flexcoders] Re: Flex 2.01 date problem

 

What you have shown is that if you use invalid data (February 29th 
of a non leap year) you get bad results. What I showed (February 3rd 
of a non leap year) was that if I use valid data I get invalid 
results.

I truly believe this is a bug.

Paul
--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Gordon Smith" <[EMAIL PROTECTED]> 
wrote:
>
> A simpler test is
> 
> 
> 
> var d:Date = new Date(1987, 1, 29);
> trace(d);
> 
> 
> 
> This traces "Sun Mar 1 00:00:00 GMT-0800 1987", presumably because 
1987
> didn't have a February 29. So I doubt waht you're seeing is a bug. 
(I'd
> have to check the Ecmascript spec to say for sure.) But it means 
that
> using Date correctly is much trickier than I ever realized!
> 
> 
> 
> Gordon Smith
> 
> Adobe Flex SDK Team 
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>

[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Matt Chotin
> Sent: Tuesday, July 29, 2008 2:31 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: Re: [flexcoders] Re: Flex 2.01 date problem
> 
> 
> 
> Try setting the date before you set the month? I think setting the 
month
> while the current day is later than 28 is going to roll the month 
on you
> potentially? Just by reording that I got it to work. When I tried 
to set
> the Date's time to 0 to avoid it using the current date that 
didn't seem
> to fix things...
> 
> It does feel like an odd error though. Might be worth filing a 
Flash
> Player bug at http://bugs.adobe.com/jira.
<http://bugs.adobe.com/jira.>  
<http://bugs.adobe.com/jira. <http://bugs.adobe.com/jira.> >
> Though would be good to test JavaScript to see if it behaves the 
same.
> 
> Matt
> 
> On 7/29/08 2:14 PM, "aceoohay" <[EMAIL PROTECTED]
> <mailto:pauls%40compuace.com> > wrote:
> 
> Just as a test I used the following;
> 
> dtTest = new Date(1987,1,3,0,0,0,0);
> 
> This returned;
> 
> dtTest.toDateString()=Tue Feb 3 1987
> 
> which is what I expected. I am so confused.
> 
> Any ideas?
> 
> Paul
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> , "aceoohay" <pauls@> wrote:
> >
> > The following code yields unexpected results on a date;
> >
> > var dtTest:Date = new Date;
> > dtTest.fullYear = 1987;
> > dtTest.month = 1;
> > dtTest.date = 3;
> > trace('dtTest.toDateString()=' +
> > dtTest.toDateString());
> >
> > The result is;
> >
> > dtTest.toDateString()=Tue Mar 3 1987
> >
> > It is my understanding that this should be February not March.
> What am
> > I doing wrong? or is there a bug in the Date object?
> >
> > Paul
> >
>

 

Reply via email to