Hey all, I sure hope someone out there can make sense of the chaos that seems to be dates.

I recently discovered the hard way that flex dates are in UTC by default when you create them, when you send them as a parameter to a C# web service, you need to use the .ToLocalTime() method (in c#) because, by default, C# uses local times.  I was trying to compare a date created in Flex as:

var dtFlex:Date = new Date(1974, 0, 26); // should be jan 26th 1974, flex months are indexed at 0

on the C# side it was:

DateTime dtCSharp = new Date(1974, 1, 26); // should be jan 26th 1974, c# months are indexed at 1

when I passed dtFlex to the web service, then on the C# side tried to compare it to dtCSharp, they were not coming back equal.  Reason was, inside, Flex actually made its date 01/26/1974 8:00 AM (I'm on pacific time here).  It was automatically making the date in UTC format.  To actually make the comparison I had to do this:

if (dtFlex.ToLocalTime() == dtCSharp)...

That was headache enough.  My main problem though is when I go the other direction, where I call a C# web service that returns a date.  In the web service explorer in flex it recognizes the result property as a date.  Well, sorta, it actually says "dateTime" for the type.  I see that's not exactly the same as Date, and I imagine thats part of the problem.  Anyway, when I try to display that result it evaluates to "Invalid Date".  When I look at the Network Monitor to see what is actually being returned by the web service, this is what I see:

<StartDate>1974-01-26T00:00:00</StartDate>

Now I'm assuming that this is not the format Flex expects for a date?  If not, I guess it's easy enough to make my own date parser, but it seems like this should just work.  Is there some specific format I am supposed to return the date in from the C# side?  Or is there something I need to do on the Flex side to make this equation happy?  Please, any help would be appreciated, I'm pulling my hair out here.  Dates are only fun if they are with a woman... :(

-- Matthew


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




Yahoo! Groups Links

Reply via email to