Bah. Obviously I'm not testing any of this myself - I'm leaving that up to you!
A call to new Date(0).getTime() will just return 0, so that won't work. What you need is the number of milliseconds *between* 1 AD 00:00:00 UTC and Jan 1, 1970 00:00:00 UTC. I don't think there's a way to use ActionScript's Date class to determine this. You can use a different technology (Java's GregorianCalendar class, for example) or just extrapolate an approximation of that value. It will be a constant once determined. (1970-1 = 1969) yrs * 365.25 days/yr * 24 hrs/day * 3600 secs/hr * 1000 ms/sec * 10000 timeticks/ms = 621369144000000000 timeticks (100ns) (This is definitely an approximation, since there aren't precisely 365.25 days per year, and it doesn't account for leap seconds, etc., but it might be close enough) Adjust CurrentTimeTicks by that constant and pass it to Date(), converting to milliseconds somewhere along the way: new Date( (CurrentTimeTicks - 621369144000000000) / 10000 ) or: new Date( CurrentTimeTicks/10000 - 62136914400000 ) Hope that gets you a bit closer to a solution. --- In [email protected], "Doug Lowder" <[EMAIL PROTECTED]> wrote: > > Sorry, I missed a parameter in there - that should have been "new Date > (0)". > > new Date( CurrentTimeTicks / 10000 - new Date(0).getTime() ) > > If you truly have a 100ns count since 1 AD as CurrentTimeTicks (the > math works out, but you should still verify that with the webservice > if possible), then you would need to adjust for the difference > between CurrentTimeTicks=0 (presumably Jan 1, 1 AD 00:00:00 UTC) and > Date(0) (Jan 1, 1970 00:00:00 UTC) and pass that to Date() after > converting to milliseconds along the way. > > > --- In [email protected], "Mark" <markp.shopping_id@> > wrote: > > > > I tried a few things along those lines and not even getting > close... > > really: > > > > setDate = new Date(nanoSeconds/10000000 - new Date().getTime()); > > RETURNS Tue Jun 20 09:55:17 GMT-0400 1933 > > > > setDate = new Date(nanoSeconds/(60*10000000) - new Date().getTime > > ()); RETURNS Tue Jun 30 09:26:26 GMT-0400 1931 > > > > setDate = new Date(nanoSeconds/(60*10000000) - new Date > > (1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 12 19:17:43 GMT- 0500 > > 1970 > > > > setDate = new Date(nanoSeconds/10000000 - new Date > > (1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 3 19:43:04 GMT- 0500 > > 1972 > > > > There's a problem with the math but I'm just not able to find it. > > Any more help?? Maybe someone knows a different Web Service? > > > > Thanks, > > Mark > > > > > > > > --- In [email protected], "Doug Lowder" <douglowder@> > > wrote: > > > > > > CurrentTimeTicks looks like a 100ns count from the year 1 AD. > You > > > could try: > > > > > > new Date( CurrentTimeTicks/10000 - new Date().getTime() ) > > > > > > Then use the Date.toString() or Date.toUTCString() method to > > examine > > > the result. You may need to adjust if CurrentTimeTicks isn't > > > relative to UTC. > > > > > > Also, don't assume daylight savings time is always a one-hour > > > offset. Some time zones work from increments of a quarter- hour. > > You > > > have the UtcOffsetTicks available to give you the correct offset. > > > > > > HTH, > > > Doug > > > > > > > > > --- In [email protected], "Mark" <markp.shopping_id@> > > > 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 [email protected], "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@ > > > > > > > > > > > > > > >

