Looking at the ASP .NET Date Tutorial at
http://www.easerve.com/developer/tutorials/asp-net-tutorials-dates.aspx
you can figure out how the dates work. Using that I came up with the
following which should help you out:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application pageTitle="World Time"
xmlns:mx="http://www.adobe.com/2006/mxml";
  width="100%" height="100%" backgroundSize="100%" layout="vertical"
horizontalAlign="left"
  creationComplete="onComplete(event)" backgroundColor="#BBDDDD" >
     <mx:Script>
         <![CDATA[
             import mx.events.FlexEvent;

             [Bindable] private var dateText:String;
             private var CurrentTimeTicks:Number = 633516008019218750;

             public function onComplete(event:FlexEvent):void
             {
                 var ticksSince1970:Number = CurrentTimeTicks -
NumTicksTo1970();
                 var msSince1970:Number = ticksSince1970 / 10000;

                 var currentDate:Date = new Date(msSince1970);

                 dateText = currentDate.toDateString() + " " +
currentDate.toTimeString();
             }

             private function NumTicksTo1970():Number
             {
                 var secondsPerDay:Number = 60 * 60 * 24;
                 var numSecondsTo1970:Number = 0;

                 for(var i:int = 1 ; i < 1970 ; i++)
                 {
                     if((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
                     {
                         numSecondsTo1970 += 366 * secondsPerDay;
                     }
                     else
                     {
                         numSecondsTo1970 += 365 * secondsPerDay;
                     }
                 }
                 return 10000000 * numSecondsTo1970;
             }
         ]]>
     </mx:Script>
     <mx:Text text="{dateText}" />
</mx:Application>




--- In flexcoders@yahoogroups.com, "Mark" <[EMAIL PROTECTED]> wrote:
>
> Actually the problem is that the CurrentTimeTicks and UtcOffsetTicks
> is returned in nanoseconds or increment of 100 nanoseconds so I
> can't use, new Date(CurrentTimeTicks);.  It returns as "not a date"
> Here's how the XML looks:
>
>
> <TimeZoneInfo>
>   <Name>Dateline Standard Time</Name>
>   <DaylightName>Dateline Daylight Time</DaylightName>
>   <StandardName>Dateline Standard Time</StandardName>
>   <DisplayName>(GMT-12:00) International Date Line
> West</DisplayName>
>   <UtcOffsetTicks>-432000000000</UtcOffsetTicks>
>   <CurrentTimeTicks>633516008019218750</CurrentTimeTicks>
>   <IsInDaylightSaving>false</IsInDaylightSaving>
> </TimeZoneInfo>
>
>
>
>
>
> --- In flexcoders@yahoogroups.com, "Josh McDonald" dznuts@
> wrote:
> >
> > All typed off the top of my head in gmail and untested:
> >
> > //Get a date for the UTC time numbers will match, but will be in
> local time
> > var foreignTime:Date = new Date(CurrentTimeTicks);
> >
> > //Strip our current (local) offset (check my -/+ math!)
> > foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 60;
> >
> > //Convert so the foreign value appears when getting the local
> value (again,
> > check +/-)
> > foreignTime.time += UtcOffsetTicks * 1000 * 60;
> >
> > if (IsDaylightSaving)
> >     foreignTime.time += 3600000;
> >
> > //Now if you fetch hours, minutes, seconds from foreignTime they
> should
> > return the numbers you'd like.
> >
> > I've probably got a couple of +/- switched around, and if the
> ticks are
> > seconds instead of ms knock off 3 zeros from some of those fields,
> but that
> > should give you a starting point :)
> >
> > When you get the correct answer, please post it to the list in a
> follow-up
> > to this thread.
> >
> > -Josh
> >
> > On Mon, Jul 14, 2008 at 11:34 PM, Mark markp.shopping_id@
> wrote:
> >
> > > I asked this question going into a weekend so I wanted to re-ask
> it
> > > today and see if anyone has any ideas on how to work this?
> > >
> > > Thank You,
> > > Mark
> > >
> > >
> > >
> > >
> >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for
> thee."
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: josh@
> >
>

Reply via email to