I've had a fair bit of experience wrestling date problems in Flex; Aside
from the fact that SchemaManager marshalls xsi:Date as Zulu time instead of
local (which isn't technically incorrect, just annoying as hell for us
aussies), every time there's a problem it's because Flex is doing the right
thing, and the server is sending an incorrect value, or what the clients
actually want is not possible without also passing along the server timezone
in another field.

For you aussies out there, the easiest way to cut down on these problems is
to use midday instead of midnight when you're referring to an "all day" date
using a Flash Date or xsi:DateTime. We do this by filtering requests and
responses on the server-side, and a subclass of DateField that sets the time
values to midday (as well as letting you 'unset' the date value) on the
client side.

If you're getting yesterday in Flex when you mean today, you've usually got
00:00:00+10:00 on the server, and it's getting truncated after being
converted to Zulu for transport somewhere. Or, you're setting a midnight
date in NSW which is +11 at the moment, and the client machine is in
Queensland which is still +10, or somewhere else which is further West. Your
server sends "(today)T00:00:00+11:00", which may or may not get converted to
Zulu as "(yesterday)13:00:00Z" in transport. The client correctly interprets
this as "23:00:00+10:00" on the client machine, which is then truncated when
displaying as  date-only display field.

Basically, if you want clients in timezone X to show times that are in
timezone Y, you need to have timezone Y be part of the information you're
sending alongside the actual datetime value, or send strings.

-Josh

On Tue, Dec 16, 2008 at 1:51 PM, Dale Fraser <d...@fraser.id.au> wrote:

>  Why does Flex do this?
>
>
>
> If I get a date out of the db and want to deal with it as a date, surely
> this should be possible. How can the flash player determine it needs to
> change it to a different date.
>
>
>
> There must be some other option rather than converting to a string.
>
>
>
> Regards
>
> Dale Fraser
>
> http://learncf.com
>
> http://flexcf.com
>
>
>
>
>
> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
> Behalf Of *Paul Kukiel
> *Sent:* Tuesday, 16 December 2008 1:46 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* Re: [flexcoders] Flex dates and time zones.
>
>
>
> Thanks Tracy,
>
>
>
> I knew I was going to get this answer.  I already got this working with
> strings as a test sample looks like I have to convert the rest of the app.
>  Surely others are feeling my pain with this issue.
>
>
>
> And Nate I look forward to seeing what you have come up with when its
> ready.
>
>
>
> Paul.
>
>
>
> On 15/12/2008, at 7:46 PM, Tracy Spratt wrote:
>
>
>
>
>
> Pass the date as a string.
>
> Tracy
>
>
>  ------------------------------
>
> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
> Behalf Of *Paul Kukiel
> *Sent:* Monday, December 15, 2008 3:17 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Flex dates and time zones.
>
>
>
> I have a date in a server in Australia:  22/12/2008 12:00:00 AM
>
> I am using this label function for the grid to try and fix the time zone
> issue but my date always comes back to me as 21/12/2008 in the datagrid.  I
> really just wan the exact date from the database regardless of where I am in
> the world.
>
> Any ideas?
>
>
> // Label Grid Date
>         public static function labelGridDate(item:Object,
> column:DataGridColumn):String {
>             var formatter:DateFormatter = new DateFormatter();
>             var myDate:Date = item[column.dataField];
>             formatter.formatString = "DD MMM YYYY";
>
>             var offsetMilliseconds:Number =
> item[column.dataField].getTimezoneOffset() * 60 * 1000;
>             item[column.dataField].setTime(item[column.dataField].getTime()
> + offsetMilliseconds);
>
>             return formatter.format(item[column.dataField]);
>         }
>
> Paul.
>
>
>
>
>
>
>
>
>  
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Like the cut of my jib? Check out my Flex blog!

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: j...@gfunk007.com
:: http://flex.joshmcdonald.info/
:: http://twitter.com/sophistifunk

Reply via email to